4 LONG_USAGE
='Import hg repository <repo> up to either tip or <max>'
16 while case "$#" in 0) break ;; esac
33 if [ "$#" != 1 ] ; then
40 # make sure we have a marks cache
41 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
42 touch "$GIT_DIR/$PFX-$SFX_MARKS"
45 GIT_DIR
="$GIT_DIR" python
"$ROOT/hg2git.py" \
48 "$GIT_DIR/$PFX-$SFX_MARKS" \
49 "$GIT_DIR/$PFX-$SFX_HEADS" \
50 "$GIT_DIR/$PFX-$SFX_STATE" \
51 | git-fast-import
--export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
52 || die
'Git fast-import failed'
54 # move recent marks cache out of the way...
55 if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
56 mv "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old"
58 touch "$GIT_DIR/$PFX-$SFX_MARKS.old"
61 # ...to create a new merged one
62 cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
63 |
uniq > "$GIT_DIR/$PFX-$SFX_MARKS"
66 rm -rf "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"
68 # save SHA1s of current heads for incremental imports
69 # and connectivity (plus sanity checking)
70 for head in `git branch | sed 's#^..##'` ; do
71 id
="`git-rev-parse $head`"
73 done > "$GIT_DIR/$PFX-$SFX_HEADS"
75 # check diff with color:
76 # ( for i in `find . -type f | grep -v '\.git'` ; do diff -u $i $REPO/$i ; done | cdiff ) | less -r