Is it possible to change dir name in repository by svndumpfilter?
Asked Answered
C

4

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?

Cimbri answered 28/9, 2009 at 10:55 Comment(0)
C
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
Circumfuse answered 7/10, 2009 at 10:46 Comment(5)
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.Hippomenes
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/…Circumfuse
That is awesome. It works. It it the only simple way how to move with folders in svn dump!Revolt
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).Etana
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.Etana
B
8

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.

Broderic answered 26/9, 2015 at 3:48 Comment(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.Etana
C
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
Circumfuse answered 7/10, 2009 at 10:46 Comment(5)
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.Hippomenes
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/…Circumfuse
That is awesome. It works. It it the only simple way how to move with folders in svn dump!Revolt
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).Etana
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.Etana
M
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…

Manhole answered 13/6, 2018 at 1:0 Comment(0)
C
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.

Cerda answered 9/2, 2020 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.