SVN: import subfolder as new repository root

I’ve done a little research and found the partial solution here: http://stackoverflow.com/questions/2337470/svn-move-single-directory-into-other-repository-with-history

Problem was that using it would error as it tries to create the subfolder.
So I dug some more and then found:
http://www.pakettiradio.net/the_ultimate_subversion_repository_splitting_guide/

Problem here was that I still had the root of the sub-folder creation attempt raising
svnadmin: File not found: transaction ‘0-1’, path

A little digging turned up:
http://www.celticwolf.com/blog/2010/05/03/subversion-svnadmin-load-error-file-not-found-transaction-0-1-path/

Which doesn’t solve anything but lit my Eureka bulb: there is no sense in creating an empty root folder. It already exists. So What I did was to delete it’s creation from the fixed dump file which was looking like this notice empty Node-path and action “add”):

Node-path:
Node-action: add
Node-kind: dir
Prop-content-length: 10
Content-length: 10

PROPS-END

Not to be confused with other empty Node-path which actually set properties!!!

Now remains only 1 problem: I also want the user to be changed. This is a problem because in the dump, the username is preceded by a line starting with V followed by a number. This number is the length of the username.

There are some interesting solutions here: http://stackoverflow.com/questions/1195339/is-there-a-way-to-change-a-svn-users-username-through-the-entire-repository-hist

However, I am trying to keep my server yum-compatible, and svndumptool is in no public yum repo, to my searching today.
My solution involves a multiline SED. Relevant articles are
http://www.refining-linux.org/archives/27/20-Multi-line-sed-search-and-replace/
and
http://stackoverflow.com/questions/4510813/sed-regular-expression-over-multiple-lines

As I have multiple subfolders to be split up into new repositories, I’ve created a script to do the job, including setting up an apache vhost for each.

The relevant part of the script looks like this:

1
2
3
4
5
6
svndumpfilter include $grp/$usr --drop-empty-revs --renumber-revs  < $repo_dump > $repo_dump.$usr
sed -e "s/Node-path: $grp\/$usr/Node-path: /" < $repo_dump.$usr >$repo_dump.$usr.fixed1
sed -e "s/Node-copyfrom-path: $grp\/$usr/Node-copyfrom-path: /" < $repo_dump.$usr.fixed1 >$repo_dump.$usr.fixed2
sed -e "/Node-path: /{ N; N; N; N; N; N; s/Node-path: \nNode-action: add\nNode-kind: dir\nProp-content-length: 10\nContent-length: 10\n\nPROPS-END//}" < $repo_dump.$usr.fixed2 >$repo_dump.$usr.fixed3
sed -e "/svn:author/{ N; N; s/svn:author\n.*\n$svn_usr_from/svn:author\nV $svn_usr_len\n$svn_usr_to/}" < $repo_dump.$usr.fixed3 >$repo_dump.$usr.fixed4
svnadmin load $repo_dir/$cust_group/$cust_customer --ignore-uuid < $repo_dump.$usr.fixed4

Related posts

Tags:

Leave a Reply

This blog is kept spam free by WP-SpamFree.