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