Currently I have a whole bunch of Mercurial repositories in a directory. All of these are cloned from a central repository that the team pushes their changes to. I like to generally keep my local repositories up-to-date so that I can review changes. Manually running hg incoming -R some_directory on 20 different projects is a lot of work. So I automated it with a simple shell script.
This script will run incoming (or outgoing) on all of the local repositories and print the results to the console. Then I can manually sync the ones that have changed if I want.
I called this file hgcheckall.sh and run it like: ./hgcheckall.sh incoming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash # Find all the directories that are mercurial repos dirs=(`find . -name ".hg"`) # Remove the /.hg from the path and that's the base repo dir merc_dirs=( "${dirs[@]//\/.hg/}" ) case $1 in incoming) for indir in ${merc_dirs[@]}; do echo "Checking: ${indir}" hg -R "$indir" incoming done ;; outgoing) for outdir in ${merc_dirs[@]}; do echo "Checking: ${outdir}" hg -R "$outdir" outgoing done ;; *) echo "Usage: hgcheckall.sh [incoming|outgoing]" ;; esac |
I guess the next major improvement would be to capture the output and then automatically sync the ones that have changed, but I haven’t gotten around to that yet.
Hi Geoff.
Thanks for the script. I was looking for exactly this kind of “tool”, and found yours in about 20 seconds thanks to the very precise headline.
I have hacked around a little with my own version, and thought I would share back.
Mainly I have changed the two “commands” to ‘inc’ and ‘out’ as my fingers are used to typing this, and changed the actual hg commands to give a much more space-saving overview:
I might consider reinserting your original versions for the “long format” and using my short-commands as above for the abbreviated one-line format.
I also added a “io” command that gives a very concise summary like:
MyProject inc:2
SecondP inc:1 out:3
ThirdP
AnotherP out:4
but this one uses the hg-prompt extension by Steve Losh
Hope some of this is useful.
Regards Jan
hi
you can do it like that to
find . -name “.hg” -exec hg -R ‘{}/..’ incoming \; -exec hg -R ‘{}/..’ outgoing \;
thx for inspiration
enjoy your stay on earth