9

Is it possible to rename directory in svn repository.

Not create new revision in which this directory will be renamed.

I would like to change the name of this directory starting from the first revision.

As far as I understand svndumpfilter utility can be used for this.

Is it correct?

Does anyone can give me small example how to do it?

4 Answers 4

7

You should svnadmin dump your repository, process the dump file and svnadmin load the processed file in an empty repo. No svndumpfilter needed.

svnadmin dump /repos/path > old.dump

The dump file can be processed with Sed or another tool (be sure that binary data doesn't get corrupted) and replace the directory name. For example:

sed -b -e "s#^\(Node.*path\): dir1/dir_old#\1: dir1/dir_new#" old.dump > new.dump

Once you've finished processing the dump file:

svnadmin create /newrepos/path
svnadmin load /newrepos/path < new.dump
5
  • 3
    do not process a complex data structure like a svn dump with a simple tool like sed. No-one guarantees you that the string ': dir1' never appears somewhere else.
    – reto
    Oct 19, 2011 at 17:36
  • 2
    In that case you would get a 'Checksum mismatch' error when loading the processed file. See dump file format: svn.apache.org/repos/asf/subversion/trunk/notes/…
    – fglez
    Oct 21, 2011 at 7:47
  • That is awesome. It works. It it the only simple way how to move with folders in svn dump! Apr 29, 2014 at 12:22
  • Unfortunately, in my experience, this will generally not work unless the replacement text has the same number of characters as the original text and you strip the checksums out of the dump file. BTW, the svndumptransformer (Marco's answer) worked for me on a fairly complicated edit (file names, comments, and file content all had to be edited).
    – arr_sea
    Jul 27, 2018 at 18:06
  • Given others success mentioned here several years ago, I wonder if the dump file format used to be such that this approach could work, but I have found that it isn't generally this easy anymore.
    – arr_sea
    Jul 27, 2018 at 18:14
7

I'd certainly recommend not to use sed, because it is unaware of the file format and you might easily render the SVN dump file unusable.

Additionally, if you want to replace a bit more than just a path, you need to either update or simply remove the SHA1 and MD5 check-sums, too.

Modifying an SVN dump is really not as trivial as it might seem at first.

I had the same problem, yesterday, and I wrote a little program for this purpose. I published it here for everyone to use:

https://github.com/nlmarco/svndumptransformer

It's free software and you're welcome to modify it, if you want/need more features.

This program modifies only text content (if a file - e.g. an image - is marked to have the mime-type "application/octet-stream", it is not modified). And since it really reads and understands the SVN dump format, it does not modify structural data belonging to the SVN dump - unlike the sed command above.

For me, this program as it currently is worked fine in renaming a product - causing all paths as well as project configuration files (=> gradle) and a few dozen Java classes to be renamed.

I hope that this program is useful to other people, too.

Btw. I'm aware that this question is very old, but I hope that my answer might help others who encounter this problem, now.

1
  • Thank you! This worked for me on a fairly complicated edit on a 2.4GB dump file (file names, directory names, comments, and file content all had to be edited). It would have been nice to have regular expression support to avoid false-positive replacements, but in my case, I there were only a few so I was able to repair them manually.
    – arr_sea
    Jul 27, 2018 at 18:09
1

https://metacpan.org/pod/release/SALVA/SVN-DumpReloc-0.02/bin/svn-dump-reloc looks interesting but does not (as it says) check for missing or duplicate directories. Going to write something custom…

0

If your ultimate goal is to import everyting into git, but you want to clean things up first, then svn-all-fast-export (unfortunately not the only one also known as svn2git) did create the best experience for me, by far (having tried svn2git with and without svndumpfilter and svndumptransformer before).

Documentation is at https://techbase.kde.org/Projects/MoveToGit/UsingSvn2Git, explaining the use in migrating the KDE project's Subversion repositories (originally migrated from CVS) to git.

The tool is at https://github.com/svn-all-fast-export/svn2git, which includes sample configuration files for common tasks. More complex configuration files for the pretty complex KDE migration process (with decades of structure changes) are at https://cgit.kde.org/kde-ruleset.git/.

The only downside I noticed was that apparently, you cannot merge two paths into one master branch. But this is easily circumvented by a final branch rename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.