chris@1544: #!/bin/sh chris@1544: chris@1544: # Copyright (c) 2007, 2008 Rocco Rutte and others. chris@1544: # License: MIT chris@1544: chris@1544: ROOT="`dirname $0`" chris@1544: REPO="" chris@1544: PFX="hg2git" chris@1544: SFX_MARKS="marks" chris@1544: SFX_MAPPING="mapping" chris@1544: SFX_HEADS="heads" chris@1544: SFX_STATE="state" chris@1544: QUIET="" chris@1544: PYTHON=${PYTHON:-python} chris@1544: chris@1544: USAGE="[-r ] -R " chris@1544: LONG_USAGE="Print SHA1s of latest changes per branch up to useful chris@1544: to reset import and restart at . chris@1544: If is omitted, use last hg repository as obtained from state file, chris@1544: GIT_DIR/$PFX-$SFX_STATE by default. chris@1544: chris@1544: Options: chris@1544: -R Hg revision to reset to chris@1544: -r Mercurial repository to use chris@1544: " chris@1544: chris@1544: . "$(git --exec-path)/git-sh-setup" chris@1544: cd_to_toplevel chris@1544: chris@1544: while case "$#" in 0) break ;; esac chris@1544: do chris@1544: case "$1" in chris@1544: -r|--r|--re|--rep|--repo) chris@1544: shift chris@1544: REPO="$1" chris@1544: ;; chris@1544: -*) chris@1544: # pass any other options down to hg2git.py chris@1544: break chris@1544: ;; chris@1544: *) chris@1544: break chris@1544: ;; chris@1544: esac chris@1544: shift chris@1544: done chris@1544: chris@1544: # for convenience: get default repo from state file chris@1544: if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then chris@1544: REPO="`grep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`" chris@1544: echo "Using last hg repository \"$REPO\"" chris@1544: fi chris@1544: chris@1544: # make sure we have a marks cache chris@1544: if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then chris@1544: touch "$GIT_DIR/$PFX-$SFX_MARKS" chris@1544: fi chris@1544: chris@1544: GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \ chris@1544: --repo "$REPO" \ chris@1544: --marks "$GIT_DIR/$PFX-$SFX_MARKS" \ chris@1544: --mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \ chris@1544: --heads "$GIT_DIR/$PFX-$SFX_HEADS" \ chris@1544: --status "$GIT_DIR/$PFX-$SFX_STATE" \ chris@1544: "$@" chris@1544: chris@1544: exit $?