Skip to content

Instantly share code, notes, and snippets.

@ogavrisevs
Created October 17, 2012 14:20
Show Gist options
  • Save ogavrisevs/3905761 to your computer and use it in GitHub Desktop.
Save ogavrisevs/3905761 to your computer and use it in GitHub Desktop.
Simple script for mercurial routine command autommation.
#!/bin/bash
#
# Simple script for mercurial routine command autommation.
# Execute mercurial commands for all repos found in current dir.
#
# Exmaple Usage
#
# $. <- current dir 1) hgAll.sh in - get all incoming commits
# $../repo1 2) hgAll.sh diff - uncommitted changes
# $../repo2 3) hgAll.sh st - uncommitted changes
# . . . 4) hgAll.sh xxx - any valid hg xxx command
# $../repo_x
#
# @ no rights reserved
function goToDir {
cd $1
}
allowedHgSubCmd=( "diff" "in" "st")
hgCmdFound=false
for hgCmd in "${allowedHgSubCmd[@]}"
do
if [ "$1" = ${hgCmd} ];then
echo "found cmd " ${hgCmd}
hgCmdFound=true
fi
done
if ! $hgCmdFound ; then
echo "No hg args ! "
exit;
fi
echo " :::::::::::::::::::: try hg $1 for all sub rep ::::::::::::::::::::"
for subDir in *;do
if [ -d "$subDir"/.hg ];then
echo " :::::::::: hg $1 $subDir "
goToDir "$subDir"
hg $1
goToDir ".."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment