annotate extra/fast-export/hg-reset.sh @ 1600:ed9c467ef922 dockerise

Add hggit extension
author Chris Cannam
date Wed, 23 Aug 2017 11:32:50 +0100
parents 3ad53f43483d
children
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@1567 27 IS_BARE=$(git rev-parse --is-bare-repository) \
Chris@1567 28 || (echo "Could not find git repo" ; exit 1)
Chris@1567 29 if test "z$IS_BARE" != ztrue; then
Chris@1567 30 # This is not a bare repo, cd to the toplevel
Chris@1567 31 TOPLEVEL=$(git rev-parse --show-toplevel) \
Chris@1567 32 || (echo "Could not find git repo toplevel" ; exit 1)
Chris@1567 33 cd $TOPLEVEL || exit 1
Chris@1567 34 fi
Chris@1567 35 GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1)
chris@1544 36
chris@1544 37 while case "$#" in 0) break ;; esac
chris@1544 38 do
chris@1544 39 case "$1" in
chris@1544 40 -r|--r|--re|--rep|--repo)
chris@1544 41 shift
chris@1544 42 REPO="$1"
chris@1544 43 ;;
chris@1544 44 -*)
chris@1544 45 # pass any other options down to hg2git.py
chris@1544 46 break
chris@1544 47 ;;
chris@1544 48 *)
chris@1544 49 break
chris@1544 50 ;;
chris@1544 51 esac
chris@1544 52 shift
chris@1544 53 done
chris@1544 54
chris@1544 55 # for convenience: get default repo from state file
chris@1544 56 if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
chris@1544 57 REPO="`grep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
chris@1544 58 echo "Using last hg repository \"$REPO\""
chris@1544 59 fi
chris@1544 60
chris@1544 61 # make sure we have a marks cache
chris@1544 62 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
chris@1544 63 touch "$GIT_DIR/$PFX-$SFX_MARKS"
chris@1544 64 fi
chris@1544 65
chris@1544 66 GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \
chris@1544 67 --repo "$REPO" \
chris@1544 68 --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
chris@1544 69 --mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \
chris@1544 70 --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
chris@1544 71 --status "$GIT_DIR/$PFX-$SFX_STATE" \
chris@1544 72 "$@"
chris@1544 73
chris@1544 74 exit $?