hg2git.py: Map 'HEAD', 'default' and '' hg branches to 'master' in git
[fast-export/benizi.git] / hg-reset.sh
blob63d7fe1afc794d877e73f37803ad2301d9e8a2bb
1 #!/bin/sh
3 # Copyright (c) 2007 Rocco Rutte <pdmef@gmx.net>
4 # License: MIT <http://www.opensource.org/licenses/mit-license.php>
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}
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.
21 Options:
22 -R Hg revision to reset to
23 -r Mercurial repository to use
26 . git-sh-setup
27 cd_to_toplevel
29 while case "$#" in 0) break ;; esac
31 case "$1" in
32 -r|--r|--re|--rep|--repo)
33 shift
34 REPO="$1"
36 -*)
37 # pass any other options down to hg2git.py
38 break
41 break
43 esac
44 shift
45 done
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\""
53 # make sure we have a marks cache
54 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
55 touch "$GIT_DIR/$PFX-$SFX_MARKS"
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 "$@"
65 exit $?