Skip to content

Instantly share code, notes, and snippets.

@cointoss1973
Created August 16, 2012 07:54
Show Gist options
  • Save cointoss1973/3368195 to your computer and use it in GitHub Desktop.
Save cointoss1973/3368195 to your computer and use it in GitHub Desktop.
Mercurialにて最後にpushされたリポジトリ群を取得するスクリプト
#!/bin/bash
if [[ -z $1 ]]; then
echo "Usage: $0 repository"
exit 1;
fi
function getFirstRev # $1: Repository path
{
if [[ $(uname -s) = MINGW* ]]; then
export LANGUAGE=C
else
export LANG=C
fi
TMP=/tmp/tmp.hg.$$
hg rollback --dry-run -R$1 > $TMP
rollbackrev=`sed -e 's/repository tip rolled back to revision \([0-9-]*\) (undo commit)/\1/' $TMP`
rm $TMP
firstrev=`expr $rollbackrev + 1`
echo $firstrev
}
### for example (after a changegroup has been added via pull)
HG_NODE=`getFirstRev $1`
hg log -r "$HG_NODE:tip" -R$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment