Created
March 7, 2012 17:05
-
-
Save stantonk/1994409 to your computer and use it in GitHub Desktop.
Perform batch "pull -u" on multiple Mercurial repositories from the parent directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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`