summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-05-30 00:56:05 +0100
committerColin Guthrie <colin@mageia.org>2013-05-30 00:56:05 +0100
commitcc1fc2877fb60215d3d315a3de6c4289aee2db52 (patch)
tree6fbd5ae40d87bcc76783272e1cb87db101f56dae
parent9b26365220224459f28678c2040b3395819a4c95 (diff)
downloadsvn-git-migration-cc1fc2877fb60215d3d315a3de6c4289aee2db52.tar
svn-git-migration-cc1fc2877fb60215d3d315a3de6c4289aee2db52.tar.gz
svn-git-migration-cc1fc2877fb60215d3d315a3de6c4289aee2db52.tar.bz2
svn-git-migration-cc1fc2877fb60215d3d315a3de6c4289aee2db52.tar.xz
svn-git-migration-cc1fc2877fb60215d3d315a3de6c4289aee2db52.zip
Support a finer grained initial conversion commit.
As some sources were imported gradually in different commits, it's neater to squash those commits together, even if this means doing it out of order. This causes less file churn overall and prevents the whole delete and readd problem (breaking git blame and friends). Sadly due to the use of binary data in the svn commits which 'patch' cannot apply, we have to use svn merging to ensure things are done properly. This means creating a dummy svn repo and synthesising commits before exporting it to form the initial squashed commit.
-rwxr-xr-xscripts/mageia-reset-and-import.sh65
1 files changed, 61 insertions, 4 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh
index 7ffeaf5..cb5fcb6 100755
--- a/scripts/mageia-reset-and-import.sh
+++ b/scripts/mageia-reset-and-import.sh
@@ -60,7 +60,8 @@ fi
echo
echo "I will now run 'svn log' on the software. You should be able to guess the right revision"
echo "to base the import on. When done, simply copy (or remember) the revision number and enter it"
-echo "into this script."
+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
@@ -69,11 +70,29 @@ svn log $NEWSVNURL/$SOFTWARE | less
echo
echo "OK you're back :)"
-echo "What was the revision number?"
+echo "What was the initial revision number?"
read revision
+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
+morerevisionsx=$(echo $morerevisionsx | trim)
+if [ -n "$morerevisionsx" ]; then
+ for rev in $morerevisionsx; do
+ rev=$(echo $rev | sed 's/r//g')
+ rev=$(( $rev + 0 ))
+ if [ $rev -gt 0 ]; then
+ morerevisions="$morerevisions $rev"
+ fi
+ done
+ echo
+ echo "OK, you said you also wanted to squash the following commits:"
+ echo " $morerevisions"
+ echo
+fi
+echo
echo "The next step is the dangerous bit. We will clear out all files in the current"
echo "working copy, run an svn export and then drop you to a shell to investigate the differences"
echo "In that shell you must git add any new files that appear and ensure you are happy with"
@@ -85,7 +104,33 @@ git reset --hard trunk
resetsha1=$(git rev-list --max-count=1 HEAD)
# The below is a "safer" verion of rm -rf * that also deletes hidden files
find . -depth -not -iwholename '.' -not -iwholename "./.git" -not -iwholename "./.git/*" -not -iwholename "./.git/.*" -delete
+
+# We have to create a subversion repository here for the import as we need a repository
+# for the svn merging below... svn sucks.
+mkdir -p svn-sucks-balls/export
+cd svn-sucks-balls/export
svn export --force --ignore-keywords --ignore-externals -r $revision $NEWSVNURL/$SOFTWARE/trunk .
+cd ../..
+svnadmin create svn-sucks-balls/repo
+svnrepo=file://$(pwd)/svn-sucks-balls/repo
+svn import -m "Import" svn-sucks-balls/export $svnrepo
+svn checkout $svnrepo svn-sucks-balls/checkout
+cd svn-sucks-balls/checkout
+if [ -n "$morerevisions" ]; then
+ for rev in $morerevisions; do
+ svn merge -c $rev --ignore-ancestry --accept theirs-full --allow-mixed-revisions $NEWSVNURL/$SOFTWARE/trunk .
+ svn commit -m "Merged r$rev"
+ if [ $? -ne 0 ]; then
+ echo
+ echo "Merging in svn revision $rev failed. You need to rethink your import strategy."
+ echo
+ exit 1
+ fi
+ done
+fi
+cd ../..
+svn export --force $svnrepo .
+rm -rf svn-sucks-balls
echo
echo "Dropping you to a shell. Use 'git status', 'git diff' and 'git add'."
echo "DO NOT run 'git commit', I'll do that later for you."
@@ -105,6 +150,12 @@ This commit consitsts of the following subversion commits:
EOF
svn log -r 1:$revision $NEWSVNURL/$SOFTWARE >>$COMMITTXT
+if [ -n "$morerevisions" ]; then
+ for rev in $morerevisions; do
+ svn log -r $rev $NEWSVNURL/$SOFTWARE | tail -n +2 >>$COMMITTXT
+ done
+fi
+
COMMITDATE=$(svn log -r $revision $NEWSVNURL/$SOFTWARE | head -n2 | tail -n1| cut -d'|' -f3 | cut -d'(' -f1 | trim)
git commit --author="Mageia SVN-Git Migration <svn-git-migration@mageia.org>" --date="$COMMITDATE" --file=$COMMITTXT -a
rm -f $COMMITTXT
@@ -127,11 +178,17 @@ echo "done"
# Keep a small log of the sha1's etc.
if [ ! -f ../svn-import.log ]; then
- echo "software,startingcommit,startingrevision,fakecommit" >../svn-import.log
+ echo "software,startingcommit,startingrevision,otherrevisions,fakecommit" >../svn-import.log
fi
-echo "drakx,$resetsha1,$revision,$sha1" >>../svn-import.log
+echo "$SOFTWARE,$resetsha1,$revision,$morerevisions,$sha1" >>../svn-import.log
echo "Continuing svn fetch"
+if [ -n "$morerevisions" ]; then
+ for rev in $morerevisions; do
+ git svn fetch -A ../authors-transform.txt -r $(( $revision + 1 )):$(( $rev - 1 ))
+ revision=$rev
+ done
+fi
git svn fetch -A ../authors-transform.txt -r $(( $revision + 1 )):HEAD
git reset --hard trunk
echo