Skip to content

Instantly share code, notes, and snippets.

@jferrao
Created June 25, 2015 22:32
Show Gist options
  • Save jferrao/e3d2c71e8a431b995959 to your computer and use it in GitHub Desktop.
Save jferrao/e3d2c71e8a431b995959 to your computer and use it in GitHub Desktop.
Mercurial pull from all subdirectories
#!/bin/bash
basedir=$(pwd -P)
for subdir in $(find . -maxdepth 1 -type d );
do
dir="$basedir"/$(basename "$subdir")
# Check if sub-directory is a Mercurial repository
if [ -n "$(hg --cwd $dir root)" ];
then
cd "$dir"
pwd
/usr/bin/expect<<EOF
spawn hg pull
expect "user:"
send "username\n"
expect "password:"
send "password\n"
interact
expect eof
EOF
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment