Open Design and Integration Environment

Converting SVN to Fossil
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com or submit via the online form
by Aug 20.

Migrating from SVN to Fossil requires an intermediary trip through GIT.

Much of the code to do this was cribbed from instructions on sqlite.org. link.

#!/bin/bash

die(){
	echo $1
	exit 1
}

authors='authors.txt'
fossilusers='users.txt'

# parameters:
# 1 - username of admin
# 2 - svn repository to convert
# 3 - name of fossil repo
# note: the repository will be created right here!

if [ "$3" == "" ]
then
	echo "Syntax:"
	echo "  svn2fossil username  svn-repo-url  fossil-repo-name"
	die  "Please make sure you have all three parameters set!"
fi

echo "Getting user names..."

svn log "$2" | grep '^r[0-9]' | cut -f3 -d' ' | sort -u > $fossilusers || die "Something went wrong getting user names"

echo "Converting user names to usable format..."
sed -e 's/.*/& = & <&>/' $fossilusers > $authors || die "Could not convert user names"

echo "Importing from SVN to git.  This will take some time, be patient!"

git svn clone --authors-file=$authors --username="$1" --no-metadata "$2" tmp || die "Unable to import to git"

echo "Importing from git to fossil.  This will also take some time, sadly"

(
cd tmp
git fast-export --full-tree --all | fossil import --git ../$3 || die "Unable to import into fossil"
)

echo "Adding users to fossil repository:"
for user in `cat $fossilusers`
do
	fossil user new $user '' "${user}1234" -R $3
	fossil user capabilities $user 'v' -R $3
done