Archive for April, 2014

SVN: import subfolder as new repository root

Sunday, April 6th, 2014

I’ve done a little research and found the partial solution here:

Problem was that using it would error as it tries to create the subfolder.
So I dug some more and then found:

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:

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-action: add
Node-kind: dir
Prop-content-length: 10
Content-length: 10


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:

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

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:

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