summaryrefslogtreecommitdiffstats
path: root/scripts/mageia-reset-and-import.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mageia-reset-and-import.sh')
-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