Fix shell substitution typo
[jelmer/fast-export.git] / hg-reset.sh
1 #!/bin/sh
2
3 # Copyright (c) 2007 Rocco Rutte <pdmef@gmx.net>
4 # License: MIT <http://www.opensource.org/licenses/mit-license.php>
5
6 ROOT="`dirname $0`"
7 REPO=""
8 PFX="hg2git"
9 SFX_MARKS="marks"
10 SFX_HEADS="heads"
11 SFX_STATE="state"
12 QUIET=""
13 PYTHON=${PYTHON:-python}
14
15 USAGE="[-r <repo>] -R <rev>"
16 LONG_USAGE="Print SHA1s of latest changes per branch up to <rev> useful
17 to reset import and restart at <rev>.
18 If <repo> is omitted, use last hg repository as obtained from state file,
19 GIT_DIR/$PFX-$SFX_STATE by default.
20
21 Options:
22         -R      Hg revision to reset to
23         -r      Mercurial repository to use
24 "
25
26 . git-sh-setup
27 cd_to_toplevel
28
29 while case "$#" in 0) break ;; esac
30 do
31   case "$1" in
32     -r|--r|--re|--rep|--repo)
33       shift
34       REPO="$1"
35       ;;
36     -*)
37       # pass any other options down to hg2git.py
38       break
39       ;;
40     *)
41       break
42       ;;
43   esac
44   shift
45 done
46
47 # for convenience: get default repo from state file
48 if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
49   REPO="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
50   echo "Using last hg repository \"$REPO\""
51 fi
52
53 # make sure we have a marks cache
54 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
55   touch "$GIT_DIR/$PFX-$SFX_MARKS"
56 fi
57
58 GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \
59   --repo "$REPO" \
60   --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
61   --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
62   --status "$GIT_DIR/$PFX-$SFX_STATE" \
63   "$@"
64
65 exit $?