From: David Wragg Date: Mon, 13 Jun 2011 12:05:47 +0000 (+0100) Subject: hg-fast-export.sh should fail if git-fast-import fails X-Git-Url: http://crossforests.com/gitweb?a=commitdiff_plain;h=fab6d6f0257c0e7db96c32ac418c51ff5d094b0b;p=python%2Ffast-export.git hg-fast-export.sh should fail if git-fast-import fails Previously, git-fast-import could fail, and exit with a non-zero status. But the exit status of hg-fast-export.sh would not reflect this. --- 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