11 USAGE
="[-m <max>] [--quiet] [<repo>]"
12 LONG_USAGE
="Import hg repository <repo> up to either tip or <max>
13 If <repo> is omitted, use last hg repository as obtained from state file,
14 GIT_DIR/$PFX-$SFX_STATE by default."
19 while case "$#" in 0) break ;; esac
22 -r|
--r|
--re|
--rep|
--repo)
26 --q|
--qu|
--qui|
--quie|
--quiet)
30 # pass any other options down to hg2git.py
40 # for convenience: get default repo from state file
41 if [ x
"$REPO" = x
-a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
42 REPO
="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
43 echo "Using last hg repository \"$REPO\""
46 # make sure we have a marks cache
47 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
48 touch "$GIT_DIR/$PFX-$SFX_MARKS"
51 GIT_DIR
="$GIT_DIR" python
"$ROOT/hg2git.py" \
53 --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
54 --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
55 --status "$GIT_DIR/$PFX-$SFX_STATE" \
57 | git-fast-import
$QUIET --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
58 || die
'Git fast-import failed'
60 # move recent marks cache out of the way...
61 if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
62 mv "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old"
64 touch "$GIT_DIR/$PFX-$SFX_MARKS.old"
67 # ...to create a new merged one
68 cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
69 |
uniq > "$GIT_DIR/$PFX-$SFX_MARKS"
72 rm -rf "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"
74 # save SHA1s of current heads for incremental imports
75 # and connectivity (plus sanity checking)
76 for head in `git branch | sed 's#^..##'` ; do
77 id
="`git-rev-parse $head`"
79 done > "$GIT_DIR/$PFX-$SFX_HEADS"
81 # check diff with color:
82 # ( for i in `find . -type f | grep -v '\.git'` ; do diff -u $i $REPO/$i ; done | cdiff ) | less -r