I have a large (30+GB) legacy SVN repo with a lot of externals defined that needs to be cloned to a new server. As the repo was originally created in the pre SVN v1.5 days it has a lot of externals defined with absolute paths that refer back to the old server name. I want to remove all the absolute paths and make them relative so that the migration will work.
I found svndumptool via this question, it works great on some of the externals but I haven't been able to figure out a REGEX that will work for the rest of the cases.
Here are cases of the six different types of external definitions that I found in the repo by running the command: svn propget --recursive svn:externals %REPODIR_FILE%/%REPO%
CaseA https://svn.acme.com/svn/test/branches/project.x
CaseB -r 19 https://svn.acme.com/svn/test/branches/project.y
https://svn.acme.com/svn/test/branches/project.z CaseC
-r 20 https://svn.acme.com/svn/test/branches/project.z@20 CaseD
CaseE https://svn.acme.com/svn/test/branches/project.x CaseE
CaseF -r21 https://svn.acme.com/svn/test/branches/project.y
Note that CaseE is the same as CaseA except for the double spacing before the https.
Note that CaseF is almost the same as CaseB except for the space between the -r and the tag number and the double spacing before the https.
I'm using rubular.com to test my REGEX, currently I'm using the following expression:
^(\S+) (|-r ?\d* ?)https:\/\/svn.acme.com(\S+)
Which gives me:
Match 1
1. CaseA
2.
3. /svn/test/branches/project.x
Match 2
1. CaseB
2. -r 19
3. /svn/test/branches/project.y
I haven't been able to come up with a REGEX that would parse cases C and D into something like the following:
Match 3
1. /svn/test/branches/project.z
2.
3. CaseC
Match 4
1. -r 20
2. /svn/test/branches/project.z@20
3. CaseD
svndumptool does seem to require that I split out the different components of the external definition so that it can correctly reassemble it in the correct (SVN v1.5) syntax.
Any help from the REGEX gods would be much appreciated :-)
In case someone using Python ends up in here:
Here is the set of commands that I have found work for me, hopefully this helps someone trying to fix a borked SVN repo in the future. Remember friends don't let friends use absolute externals!
This procedure reduced the list of externals from over 30K defined externals to just 30 defined externals in the first six iterations.
Here are two choices since you're using Ruby. However, do you have any other regular expression flavor on your machine ?
1st Choice (Absolute path AND 3 matches)
Demo
http://rubular.com/r/dBMVd1arVJ
2nd Choice (Relative path AND multiple matches)
Demo
http://rubular.com/r/f3t3OH5Wqn