diff --git a/hg-fast-export.sh b/hg-fast-export.sh index 718eb18..334f286 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -71,6 +71,9 @@ if [ ! -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then touch "$GIT_DIR/$PFX-$SFX_MARKS" fi +# cleanup on exit +trap 'rm -f "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp"' 0 + GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-fast-export.py" \ --repo "$REPO" \ --marks "$GIT_DIR/$PFX-$SFX_MARKS" \ @@ -78,7 +81,7 @@ GIT_DIR="$GIT_DIR" $PYTHON "$ROOT/hg-fast-export.py" \ --heads "$GIT_DIR/$PFX-$SFX_HEADS" \ --status "$GIT_DIR/$PFX-$SFX_STATE" \ "$@" \ -| git fast-import $GFI_OPTS --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" +| git fast-import $GFI_OPTS --export-marks="$GIT_DIR/$PFX-$SFX_MARKS.tmp" || exit 1 # move recent marks cache out of the way... if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then @@ -91,9 +94,6 @@ fi cat "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" \ | uniq > "$GIT_DIR/$PFX-$SFX_MARKS" -# cleanup -rm -rf "$GIT_DIR/$PFX-$SFX_MARKS.old" "$GIT_DIR/$PFX-$SFX_MARKS.tmp" - # save SHA1s of current heads for incremental imports # and connectivity (plus sanity checking) for head in `git branch | sed 's#^..##'` ; do