From: Rocco Rutte Date: Thu, 8 Mar 2007 11:16:28 +0000 (+0000) Subject: hg2git.sh: Try to get last hg repo url from state file X-Git-Url: http://crossforests.com/gitweb?a=commitdiff_plain;h=61bb1cb70794df21b626159ff164839d7915907e;p=python%2Ffast-export.git hg2git.sh: Try to get last hg repo url from state file As one usually mirrors a git repo based on the same hg repo, it's annoying having to specify the hg repo url all the time. Since we intentionally stored the url in the state file already, use in the shell wrapper and default to it. Signed-off-by: Rocco Rutte --- diff --git a/hg2git.sh b/hg2git.sh index 46ce727..5de3270 100755 --- a/hg2git.sh +++ b/hg2git.sh @@ -1,7 +1,5 @@ #!/bin/sh -USAGE='[-m max] [--quiet] repo' -LONG_USAGE='Import hg repository up to either tip or ' ROOT="`dirname $0`" REPO="" MAX="-1" @@ -11,6 +9,11 @@ SFX_HEADS="heads" SFX_STATE="state" QUIET="" +USAGE="[-m ] [--quiet] []" +LONG_USAGE="Import hg repository up to either tip or +If is omitted, use last hg repository as obtained from state file, +GIT_DIR/$PFX-$SFX_STATE by default." + . git-sh-setup cd_to_toplevel @@ -34,12 +37,20 @@ do shift done -if [ "$#" != 1 ] ; then - usage - exit 1 +# for convenience: get default repo from state file +if [ "$#" != 1 -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then + REPO="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`" + echo "Using last hg repository \"$REPO\"" fi -REPO="$1" +if [ x"$REPO" = x ] ; then + if [ "$#" != 1 ] ; then + usage + exit 1 + else + REPO="$1" + fi +fi # make sure we have a marks cache if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then