11 USAGE
="[-m <max>] [--quiet] [-s] [-A <file>] [-r <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.
17 -m Maximum revision to import
18 --quiet Passed to git-fast-import(1)
19 -s Enable parsing Signed-off-by lines
20 -A Read author map from file
21 (Same as in git-svnimport(1) and git-cvsimport(1))
22 -r Mercurial repository to import
28 while case "$#" in 0) break ;; esac
31 -r|
--r|
--re|
--rep|
--repo)
35 --q|
--qu|
--qui|
--quie|
--quiet)
39 # pass any other options down to hg2git.py
49 # for convenience: get default repo from state file
50 if [ x
"$REPO" = x
-a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
51 REPO
="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
52 echo "Using last hg repository \"$REPO\""
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" \
62 --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
63 --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
64 --status "$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