File: hg-reset.sh

package info (click to toggle)
hg-fast-export 20140308-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 176 kB
  • ctags: 99
  • sloc: python: 578; sh: 460; ansic: 312; makefile: 19
file content (67 lines) | stat: -rwxr-xr-x 1,530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh

# Copyright (c) 2007, 2008 Rocco Rutte <pdmef@gmx.net> and others.
# License: MIT <http://www.opensource.org/licenses/mit-license.php>

ROOT="/usr/share/hg-fast-export"
REPO=""
PFX="hg2git"
SFX_MARKS="marks"
SFX_MAPPING="mapping"
SFX_HEADS="heads"
SFX_STATE="state"
QUIET=""
PYTHON=${PYTHON:-python}

USAGE="[-r <repo>] -R <rev>"
LONG_USAGE="Print SHA1s of latest changes per branch up to <rev> useful
to reset import and restart at <rev>.
If <repo> is omitted, use last hg repository as obtained from state file,
GIT_DIR/$PFX-$SFX_STATE by default.

Options:
	-R	Hg revision to reset to
	-r	Mercurial repository to use
"

. "$(git --exec-path)/git-sh-setup"
cd_to_toplevel

while case "$#" in 0) break ;; esac
do
  case "$1" in
    -r|--r|--re|--rep|--repo)
      shift
      REPO="$1"
      ;;
    -*)
      # pass any other options down to hg2git.py
      break
      ;;
    *)
      break
      ;;
  esac
  shift
done

# for convenience: get default repo from state file
if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
  REPO="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
  echo "Using last hg repository \"$REPO\""
fi

# make sure we have a marks cache
if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
  touch "$GIT_DIR/$PFX-$SFX_MARKS"
fi

GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-reset.py" \
  --repo "$REPO" \
  --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
  --mapping "$GIT_DIR/$PFX-$SFX_MAPPING" \
  --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
  --status "$GIT_DIR/$PFX-$SFX_STATE" \
  "$@"

exit $?