Renaming an SVN(Subversion) Repository

来源:互联网 发布:云计算的前景 编辑:程序博客网 时间:2024/04/30 13:04

最近SVN再做规范化,有些资料库名字需要更新,因此网上找了如下的方法还是挺好用的

What is SVN (Subversion)?

If you don't know what SVN is and you're reading this page, you probably got here by mistake. That's OK! However, you will probably not benefit much from this tutorial

If you decided to stick around, SVN is document versioning software commonly used by software developers as a repository for source code. Like CVS, GIT and Miscrosoft Source Safe SVN allows multiple users to work on the same document and it keeps track of changes to the documents.

If you still want to learn more, go to subversion.tigris.org

The issue: Renaming a Repository

Ok, so here's the scenarion: We have an SVN repository and we want to change it's name.

The problem is that SVN doesn't have a Rename Repository command we could use.

Why would anyonewant to rename an SVN repository? - that's a good question, and the the answer, I'm sure, depends on the case. Maybe you started off with a name for a project and later you decided to change it.

The solution: svnadmin dump & svnadmin load

The correct way to do this is to actually create a repository with the new name, and then import all revisions from the old repository into the newly created one.This way, all the revision history will be preserved(这是我要的啊~)

So, first we create a repositroy with the new name. Assuming /path/to/new/repository/ is the path where you want the new repository to be created, and<new-repo-name> is the new name, the command would look like this..

svnadmin create /path/to/new/repository/<new-repo-name>

Then we dump all the data from the old respository into a file called old-repo.dump. We will assume /the/path/to/old/repository/ is the path to the repository and that the old repository was calledold-repo-name.

svnadmin dump /the/path/to/old/repository/<old-repo-name> > old-repo.dump

Now, we can import the dump file into the newly created repository. In order to to that we use theload svn command.

svnadmin load /the/path/to/new/repository/<new-repo-name> < old-repo.dump

Wrapping up

One thing to note is that for this method to be successfull, the newly created repository has to be empty. Otherwise you may get all sorts of errors and/or funny results.

The other observation that I would make is that in case of a large project, this process may take a while and the resulting dump file and new repository may be rather large.

原创粉丝点击