Subversion Dump File Splitter
I recently had to do some mangling of a dump of my personal Subversion repository. Basically, I had to modify some paths and revision copy numbers before re-importing to a clean repository. However, the dump was in one huge 300 MiB file, making it really difficult for to open for editing.
Normally, the solution would simply be to re-dump the repository using the --revision option to the svnadmin dump command. Unfortunately, in a flash of stupidity, I deted my old repository before I had the new one working. So I wrote a little Perl script to split the dumpfile into seperate files.
#!/usr/bin/perl
open(REV, "> repo") || die("Unable to open $!");
while (<>) {
$line = $_;
if (/^Revision-number\:\s+(\d+)$/) { open(REV, "> rev.$1") || die("Unable to open $!");
if (!$header) {
open(REPO, "< repo") || die("Unable to open $!");
while () { $header = $header . $_; }
}
print REV $header; }
print REV $line;
}
Ah…short and sweet, just the way a Perl script should be. Normally, I would immediately delete any Perl that I might happen to write, as I think the language is too flexible to be properly maintained over any length of time. However, since I can’t find anything else like this out on Teh Intarweb, I figure I’ll leave it here for posterity.