12 USAGE
="[-m <max>] [--quiet] [<repo>]"
13 LONG_USAGE
="Import hg repository <repo> up to either tip or <max>
14 If <repo> is omitted, use last hg repository as obtained from state file,
15 GIT_DIR/$PFX-$SFX_STATE by default."
20 while case "$#" in 0) break ;; esac
27 --q|
--qu|
--qui|
--quie|
--quiet)
40 # for convenience: get default repo from state file
41 if [ "$#" != 1 -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 if [ x
"$REPO" = x
] ; then
47 if [ "$#" != 1 ] ; then
55 # make sure we have a marks cache
56 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
57 touch "$GIT_DIR/$PFX-$SFX_MARKS"
60 GIT_DIR
="$GIT_DIR" python
"$ROOT/hg2git.py" \
63 "$GIT_DIR/$PFX-$SFX_MARKS" \
64 "$GIT_DIR/$PFX-$SFX_HEADS" \
65 "$GIT_DIR/$PFX-$SFX_STATE" \
66 | git-fast-import
$QUIET --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
67 || die
'Git fast-import failed'
69 # move recent marks cache out of the way...
70 if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
71 mv "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old"
73 touch "$GIT_DIR/$PFX-$SFX_MARKS.old"
76 # ...to create a new merged one
77 cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
78 |
uniq > "$GIT_DIR/$PFX-$SFX_MARKS"
81 rm -rf "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"
83 # save SHA1s of current heads for incremental imports
84 # and connectivity (plus sanity checking)
85 for head in `git branch | sed 's#^..##'` ; do
86 id
="`git-rev-parse $head`"
88 done > "$GIT_DIR/$PFX-$SFX_HEADS"
90 # check diff with color:
91 # ( for i in `find . -type f | grep -v '\.git'` ; do diff -u $i $REPO/$i ; done | cdiff ) | less -r