From 01d71a2d3fd6b992b32f909a653996dd6911d290 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 28 Dec 2016 12:14:04 +0100 Subject: [PATCH] Make backup copies of state files If a conversion fails we want the previous state files preserved, both for debugging but also to allow us to recover. --- hg-fast-export.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index d0dd506..4ad6720 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -85,6 +85,13 @@ do shift done +# Make a backup copy of each state file +for i in $SFX_STATE $SFX_MARKS $SFX_MAPPING $SFX_HEADS ; do + if [ -f "$GIT_DIR/$PFX-$i" ] ; then + cp "$GIT_DIR/$PFX-$i" "$GIT_DIR/$PFX-$i~" + fi +done + # for convenience: get default repo from state file if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then REPO="`grep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"