diff options
author | Colin Guthrie <colin@mageia.org> | 2013-05-30 09:40:56 +0100 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-05-30 09:40:56 +0100 |
commit | a7240611654c5c437f4309868c2354fb688b9059 (patch) | |
tree | 83a4c53a8dcf7c3d357b59fb7e03db421d4347a7 /scripts | |
parent | cc1fc2877fb60215d3d315a3de6c4289aee2db52 (diff) | |
download | svn-git-migration-a7240611654c5c437f4309868c2354fb688b9059.tar svn-git-migration-a7240611654c5c437f4309868c2354fb688b9059.tar.gz svn-git-migration-a7240611654c5c437f4309868c2354fb688b9059.tar.bz2 svn-git-migration-a7240611654c5c437f4309868c2354fb688b9059.tar.xz svn-git-migration-a7240611654c5c437f4309868c2354fb688b9059.zip |
Add support for replaying the same conversion again.
This is mostly useful during testing, but if we have to do several
runs to ensure the data is 100% correct (i.e. picking the correct
initial svn revision to import and any subsequent commits to squash)
then reusing the data collected here (perhaps with manual log editing)
will be very useful.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mageia-reset-and-import.sh | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh index cb5fcb6..01c1f1e 100755 --- a/scripts/mageia-reset-and-import.sh +++ b/scripts/mageia-reset-and-import.sh @@ -16,6 +16,32 @@ if [ -d ../$SOFTWARE.git ]; then exit 1 fi +REPLAY= +if [ -f ../svn-import.log ]; then + REPLAYDATA=$(grep ^$SOFTWARE, ../svn-import.log | tail -n 1) + if [ -n "$REPLAYDATA" ]; then + resetsha1=$(echo $REPLAYDATA | cut -d',' -f 2) + revision=$(echo $REPLAYDATA | cut -d',' -f 3) + morerevisionsx=$(echo $REPLAYDATA | cut -d',' -f 4) + synthesized=$(echo $REPLAYDATA | cut -d',' -f 5) + + echo + echo "I have found data from a previous run:" + echo + echo "Reset SHA1: $resetsha1" + echo "Mageia Import SVN Revision: $revision" + echo "Extra SVN Revisions to squash:$morerevisionsx" + echo + echo "Do you want to reply it? [Y/n]" + read REPLAY + if [ -z "$REPLAY" -o "Y" = "$REPLAY" ]; then + REPLAY=y + else + REPLAY= + fi + fi +fi + echo -n "Finding UUID for SVN Repository $NEWSVNURL... " NEWSVNUUID=$(svn info $NEWSVNURL | grep "^Repository UUID:" | sed 's/Repository UUID: //') echo $NEWSVNUUID @@ -36,21 +62,27 @@ echo "date will be around February 2011." echo "I will drop you to a shell. When you are done, simply copy the SHA1 sum and exit." echo "The commands you like want are 'git log trunk' and 'git show SHA1'" echo -echo "Press any key to contiue." -read -n 1 -bash -echo -echo "OK you're back :)" -echo "What was the SHA1?" -read resetsha1 +if [ -z "$REPLAY" ]; then + echo "Press any key to contiue." + read -n 1 + bash + echo + echo "OK you're back :)" + echo "What was the SHA1?" + read resetsha1 +fi + if [ -z "$resetsha1" ]; then echo "You did not give any SHA1 sum. I will not reset the git repository and carry on importing" echo "from it's current state. You can quit this script and start again if this is incorrect." else echo "I got SHA1 '$resetsha1'. I hope that's correct". echo - echo "I will now reset your git trunk and master branches. Is this OK? (press ctrl+c if not)" - read -n 1 + echo "I will now reset your git trunk and master branches." + if [ -z "$REPLAY" ]; then + echo "Is this OK? (press ctrl+c if not)" + read -n 1 + fi git update-ref -m "Rewind SVN Git to pre-Magiea import" refs/remotes/trunk $resetsha1 git checkout master git reset --hard trunk @@ -63,21 +95,26 @@ echo "to base the import on. When done, simply copy (or remember) the revision n echo "into this script. You will also be able to (optionall) select several other commits which" echo "you wish to squash into this initial commit." echo -echo "Press any key to contiue." -read -n 1 +if [ -z "$REPLAY" ]; then + echo "Press any key to contiue." + read -n 1 -svn log $NEWSVNURL/$SOFTWARE | less + svn log $NEWSVNURL/$SOFTWARE | less -echo -echo "OK you're back :)" -echo "What was the initial revision number?" -read revision + echo + echo "OK you're back :)" + echo "What was the initial revision number?" + read revision +fi revision=$(echo $revision | sed 's/r//g') revision=$(( $revision + 0 )) echo "I got revision '$revision'. I hope that's correct". echo -echo "Do you also want to squash any further commits into our initial commit? Enter them here if so" -read morerevisionsx + +if [ -z "$REPLAY" ]; then + echo "Now enter any further commits you wish to squash into our initial commit:" + read morerevisionsx +fi morerevisionsx=$(echo $morerevisionsx | trim) if [ -n "$morerevisionsx" ]; then for rev in $morerevisionsx; do @@ -168,7 +205,7 @@ read -n 1 git svn gc sha1=$(git rev-list --max-count=1 HEAD) echo -echo -n "Updating trunk branch to include synthesised commit $sha1... " +echo -n "Updating trunk branch to include synthesized commit $sha1... " git update-ref -m "Reset to synthesized commit representing Magiea cleaned import (SVN Git)" refs/remotes/trunk $sha1 echo "done" @@ -177,10 +214,14 @@ printf "0000000: %08x%s\t................" $revision $sha1 | xxd -r -c24 >.git/s echo "done" # Keep a small log of the sha1's etc. -if [ ! -f ../svn-import.log ]; then - echo "software,startingcommit,startingrevision,otherrevisions,fakecommit" >../svn-import.log +if [ -z "$REPLAY" ]; then + if [ ! -f ../svn-import.log ]; then + echo "software,startingcommit,startingrevision,otherrevisions,fakecommit" >../svn-import.log + fi + echo "$SOFTWARE,$resetsha1,$revision,$morerevisions,$sha1" >>../svn-import.log +else + sed -i "s/,$synthesized\$/,$sha1/" ../svn-import.log fi -echo "$SOFTWARE,$resetsha1,$revision,$morerevisions,$sha1" >>../svn-import.log echo "Continuing svn fetch" if [ -n "$morerevisions" ]; then |