Changing Paths While Migrating Subversion Repositories – March 13, 2012

Note: This is extremely hacky, and you had better make sure you have a backup, as it is quite easy to wreck the repository.

Scenario:

I was moving a subversion repository from one server to another, and in the process, I also wanted to update the paths, since the first repository had been a general purpose repository, and the second was only for one particular customer, and so didn't need the extra path info at the beginning.

I started with these instructions: http://svnbook.red-bean.com/en/1.5/svn.reposadmin.maint.html#svn.reposadmin.maint.filtering and they got me almost all of the way there.  However, I had problems with one revision that contained some merge information in it.

The error I got was: pathname not terminated by :

The problem was that I had replaced:

Node-path: SAMS/framework/mine
Node-kind: dir
Node-action: change
Prop-content-length: 90
Content-length: 90

K 13
svn:mergeinfo
V 55
/SAMS/framework/current:4-9
/SAMS/framework/tags/3.6:10
PROPS-END

with:

Node-path: framework/mine
Node-kind: dir
Node-action: change
Prop-content-length: 90
Content-length: 90

K 13
svn:mergeinfo
V 55
/framework/current:4-9
/framework/tags/3.6:10
PROPS-END

And that isn't quite right.  The key is realizing what the "V 55" part means and that is counting the number of characters that is in the next section, and since I removed 10 characters (I removed "/SAMS" twice in the same block).  Replacing "V 55" with "V 45" and tada, it works.

I suppose that the Content-length field should be updated as well, but subversion seems to be able to tolerate text changes without updating that field.