First: There are several tools called svn2git: this is about the svn2git of KDE up on Gitorious. So you're about to convert a larger SVN repository to Git, say 15,000 revisions. You check out the latest revision, run some find command or fire up a file browser to get a better view of file hierarchy in there. Then it strikes you:
- What if the layout didn't look like that all the time?
- Are there any sub projects hidden in there that you want to ignore or extract to a separate repository?
You may end up using "svn ls" or something peeping in here and there not being really sure until you've seen it all. What a nightmare. When converting the repository of Gentoo's Portage I wrote a simple tool in Python to do that work for me in automated fashion: I called it svneverever. It runs through all history collecting additions of directories. In the end it presents a tree of all directories ever having existed in the repository. Let's do a quick example. First we create tiny but suitable sample repository:
# Create and checkout dummy SVN repo svnadmin create example-store svn co file://$PWD/example-store example-workdir cd example-workdir # Make revision #1 for /trunk mkdir trunk touch trunk/readme.txt svn add trunk svn ci -m 'Add /trunk' # Make revision #2 for /project7/trunk mkdir project7 svn add project7/ svn mv trunk project7/ svn ci -m 'Move /trunk to /project7/trunk'
Let's feed that to svneverever:
Its output will be:
Analyzing 2 revisions.... 50% (r1)... 100% (r2). /project7 /trunk /trunk
(The output for Portage was more complex, have a look at all-portage-repo- dirs-ever.txt if you're curious.) With that information at hand it's easy to write a svn2git rules file for it:
create repository project7 end repository match /project7/trunk/ repository project7 branch master end match match /trunk/ repository project7 branch master end match
or this one after unification of the matchers into one:
create repository project7 end repository match (?:/project7)?/trunk/ repository project7 branch master end match
(For Portage we ended up with these rules (v3).) On one hand svneverever is a working tool already, on the other some of you will want more from it. As of now I just won't be able to handle potential feature request but I hope to have time to review and accept sets of clean patches. So if you have patches for me: please contact me. Last but not least a big THANK YOU to the authors of svn2git. It's powerful and fast: 110 minutes faster than git-svn on the history of Portage over here. Thank you (in order of current commit count, descending):
- Thiago Macieira
- Thomas Zander
- Torgny Nyblom
- Anders Kaseorg
One last time: here's the link to svneverever.