Generating empty/padding revisions in an SVN dump

I’ve previously had an SVN repository filled with a mixture of projects that I’m now splitting out into separate repositories, so am in the process of creating various scripts based on “svnadmin dump”/”svnadmin load” to process repositories.
Along the way, I had a need to dump only selected revisions from a repository, using a command such as:

svnadmin dump -r 1234:HEAD /path/to/repo > repo.dump

However, when this is loaded back into a new repository (“svnadmin load mynewrepo < repo.dump”), the revisions are renumbered starting at 1, so that what was revision 1234 becomes revision 1. This is undesirable, as I have existing bugs and changelogs referring to SVN revision numbers, so I created a small script (svn-generate-empty-revisions) to create a number of empty revisions.

In use, it’s most useful to splice its output into the start of an SVN dump, for example:

svnadmin dump -r 1234:HEAD /path/to/repo > repo.dump
# Extract the first few lines of the dump, which contain metadata
head -n 4 repo.dump > repo-padded.dump
# Splice in some empty "padding" revisions to preserve revision numbering
# Note that the first revision is 1234, so we want 1233 empty revisions at start
./svn-generate-empty-revisions.sh 1233 >> repo-padded.dump
# Add the rest of the original repository dump to the file
tail -n +4 repo.dump >> repo-padded.dump

5 Responses to “Generating empty/padding revisions in an SVN dump”

  1. Rado says:

    Tim, thanks for the script, saved me an hour!

    I’m in the process of recovering a damaged repository… somehow it contains 3 broken revisions – it worked well on our server despite this, but to migrate I need to do a dump/load, and so far I haven’t found a way to do a dump because of the damaged files…

    So now I’m attempting to do 2 separate dumps, leaving out the 3 damanged revisions (they were successive) and join them – for this I needed to replace the 3 damaged revisions with dummy ones. I modified your script slightly to generate revisions between a FROM and TO number instead of starting from 1 (it’s a simple change but if anyone’s interested I’ll post it online).

  2. nkl says:

    Great! I ran into the same problem and figured that somebody did this already. Thanks for posting the solution.

  3. Eddy says:

    Tx, this saved my day. Works like a charm

  4. Nidget says:

    It’s been of a great help. Thank you !

    I had transfer newer revisions to another server while keeping the new server in sync with the old one during the migration process (old server had to be kept for archive). This saved my life because svnsync couldn’t work on non-aligned version numbers.