Skip to content

Import from subversion

Damien Buhl edited this page Aug 7, 2014 · 10 revisions

Use the following command to import data from an SVN repository :

apt-get install svn2git
mkdir repository-name/
svn2git https://hq.ch.sauter-bc.com/svn/repository-to-import --no-minimize-url --username your-username --metadata --authors authors-file --verbose

The authors-file is used to give a valid author name to the commits, it looks like the following :

czenemar = Martin Czene <martin.czene@devpoint.org>
staudyan = Yannic Staudt <yannic.staudt@ygraphix.net> 
kraetyan = Yann Philipp Kraetzschmann <ypk@online.fr> 
kraussve = Sven Krauss <sven.krauss@ch.sauter-bc.com>
siebofab = Fabian Siebold <fabian.siebold@ch.sauter-bc.com>
eichsjul = Julian Eichstaedt <julian.eichstaedt@ch.sauter-bc.com>
eberldav = David Eberlein <david.eberlein@ch.sauter-bc.com>
buhldam = Damien Buhl (alias daminetreg) <damien.buhl@lecbna.org>
truebden = Denis Trueby <denis.trueby@ch.sauter-bc.com>
bouwerob = Robert Bouwens <robert.bouwens@ch.sauter-bc.com>
hoeneste = Stefan Hoene <stefan.hoene@ch.sauter-bc.com>
criticalvale = Nelson Vale <nf-vale@criticalsoftware.com>
frieddan = Daniel Friedrich <daniel.friedrich@ch.sauter-bc.com>

Finally you have to rewrite the history, because in Fr. Sauter AG we did commits in the following form :

[FEATURE|BUG FIX|ADMIN|EDITORIAL]:

Commit description

This is a problem in Git view of history, as you only see the first line in summary views (and only the 50 first chars of this line). This is a convention backed by Git standards overview of logs and so on. You can convert the commits to this convention with the following sed script :

/\(^\(\(REFACTORING\)\|\(BUG\)\|\(BUGFIX\)\|\(FEATURE\)\)\s*:*\s*$\)\|\(^[^:]\+:\s*$\)/ , /^\s*[A\-Za\-z0\-9-]\+/ {
	
	:concat-lines-till-first-non-empty-line
	/\(^\(\(REFACTORING\)\|\(BUG\)\|\(BUGFIX\)\|\(FEATURE\)\)\s*:*\s*$\)\|\(^[^:]\+:\s*$\)/ {
		s/\s*$/ /g;
		N;
		s/\n//;
		bconcat-lines-till-first-non-empty-line
	}

	/^\s*[A\-Za\-z0\-9-]\+/! {
		N;
		s/\n//;
		bconcat-lines-till-first-non-empty-line
	}
	
}

Run through your freshly imported git repostory :

git filter-branch --msg-filter "sed -f ~/migrationSvnGit/rewriteMsg.sed" -- --all

Subversion imports scripts