-
-
Save stantonk/1994409 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# This script finds all the mercurial repositories in the current directory | |
# and does a "hg pull -u" to get the latest changes from all the repositories. | |
# | |
# Make sure you know what you're doing before running this ;-) | |
confirm_prompt() { | |
read -p "Are you sure you want to 'hg pull -u' every repository? " -n 1 | |
echo | |
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
exit 1 | |
fi | |
} | |
confirm_prompt | |
targetDir=`pwd` | |
dirObjs=`ls $targetDir` | |
# check the current directory for mercurial repositories | |
for d in $dirObjs | |
do | |
if [ -d $d ] && [ -f "$d/.hg/hgrc" ]; then | |
echo "--------" | |
echo "Updating mercurial repository in $d" | |
cd $d | |
hg pull -u | |
cd .. | |
fi | |
done |
This is a handy script, just one suggestion though, if you can add hg update and merge for +1 heads, that will be great.
Here is a windows version for that.
`@ECHO OFF
REM This script finds all the mercurial repositories in the current directory
REM and does a "hg pull -u" to get the latest changes from all the repositories.
REM
REM Make sure you know what you're doing before running this ;-)
:choice
set /P c=Are you sure you want to 'hg pull -u' every repository? [Y/N]
if /I "%c%" EQU "Y" goto :pull
if /I "%c%" EQU "N" goto :end
goto :choice
:pull
REM check the current directory for mercurial repositories
echo
for /f "tokens=*" %%i in ('dir /ad /b') do (
cd %%i
if EXIST ..hg (
echo
echo -------- START UPDATE "%%i" --------
hg pull -u
echo --------- END UPDATE "%%i" ---------
echo
)
cd ..
)
echo
echo ALL PROJECTS UPDATED
pause
exit
:end
echo
echo UPDATE CANCELED
pause
exit`
Cool, this should come in handy!