push several local repos to bitbucket at the same time
Cameron Simpson
cs at zip.com.au
Sun Sep 4 00:54:09 UTC 2016
On 02Sep2016 11:31, Uwe Brauer <oub at mat.ucm.es> wrote:
>I have a couple of repos which I push at the end of the day to
>bitbucket, but sometimes I forget that.
You could put such a thing in your crontab.
>Is there an easy way to push these repos which live in different
>directories with one single command?
There are easy ways to script it, and such a script is a single command :-)
>I recently heard about subrepos, could that be used?
>The other option would be to use find
>Something like this
>
>find . -name ".hg" -type d -printf "\t" -execdir pwd \; -execdir hg push \; -printf "\n"
>
>Or maybe I could run a hook such that after each commit it pushed (but
>maybe that is a bit too much).
When using find like this I like to include a -prune to avoid recursing any
further. This isn't so effective when your criterion (the .hg dir) is inside
the natural prune point, but it can help.
However, find isn't really the best tool for this. Unless you are quite
disorganised, I would expect that your repos are in well defined places. For
example, I can find all my regular ones with the shell pattern:
$HOME/hg/*
and the ones I'd be prepared to push automatically are even fewer, to the point
that I'd probably just enumerate an explicit list of directories.
To that end I'd write a small shell script looking like this:
#!/bin/sh
for hgdir in $HOME/hg/css $HOME/hg/css-venti ...
do
echo "$hgdir"
( cd "$hgdir"
hg push
)
done
and just run it from cron if that is your wish.
One thing to note about using cron is that the push will need to work without
interaction from you. If you're using ssh, this will require that either you
access your existing ssh-agent or that you have a special purpose
passphraseless ssh key to use in this context.
Cheers,
Cameron Simpson <cs at zip.com.au>
More information about the Mercurial
mailing list