Is it possible to change dir name in repository by

2019-03-11 08:23发布

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?

3条回答
叼着烟拽天下
2楼-- · 2019-03-11 08:40

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…

查看更多
你好瞎i
3楼-- · 2019-03-11 08:42

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
查看更多
4楼-- · 2019-03-11 08:54

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.

查看更多
登录 后发表回答