11 USAGE
="[--quiet] [-r <repo>] [-m <max>] [-s] [-A <file>]"
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.
16 Note: The argument order matters.
19 -m Maximum revision to import
20 --quiet Passed to git-fast-import(1)
21 -s Enable parsing Signed-off-by lines
22 -A Read author map from file
23 (Same as in git-svnimport(1) and git-cvsimport(1))
24 -r Mercurial repository to import
30 while case "$#" in 0) break ;; esac
33 -r|
--r|
--re|
--rep|
--repo)
37 --q|
--qu|
--qui|
--quie|
--quiet)
41 # pass any other options down to hg2git.py
51 # for convenience: get default repo from state file
52 if [ x
"$REPO" = x
-a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
53 REPO
="`egrep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"
54 echo "Using last hg repository \"$REPO\""
57 # make sure we have a marks cache
58 if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
59 touch "$GIT_DIR/$PFX-$SFX_MARKS"
62 GIT_DIR
="$GIT_DIR" python
"$ROOT/hg2git.py" \
64 --marks "$GIT_DIR/$PFX-$SFX_MARKS" \
65 --heads "$GIT_DIR/$PFX-$SFX_HEADS" \
66 --status "$GIT_DIR/$PFX-$SFX_STATE" \
68 | git-fast-import
$QUIET --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
69 || die
'Git fast-import failed'
71 # move recent marks cache out of the way...
72 if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then
73 mv "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old"
75 touch "$GIT_DIR/$PFX-$SFX_MARKS.old"
78 # ...to create a new merged one
79 cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \
80 |
uniq > "$GIT_DIR/$PFX-$SFX_MARKS"
83 rm -rf "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"
85 # save SHA1s of current heads for incremental imports
86 # and connectivity (plus sanity checking)
87 for head in `git branch | sed 's#^..##'` ; do
88 id
="`git-rev-parse $head`"
90 done > "$GIT_DIR/$PFX-$SFX_HEADS"
92 # check diff with color:
93 # ( for i in `find . -type f | grep -v '\.git'` ; do diff -u $i $REPO/$i ; done | cdiff ) | less -r