annotate extra/fast-export/hg-reset.sh @ 1561:6074fffd8a1d feature_1136

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