假设我们有一个颠覆存储库,看起来像

/original/0.1
/original/0.2
/variantA/trunk
/variantA/branches/who/branch_for_xxx
/variantA/branches/she/branch_for_yyy
/variantB/trunk
/variantB/branches/who/branch_for_zzz
(... 30 or 40 alike)

其中variantA和variantB是原始软件的分支。

我正在寻找一种将此存储库迁移到分布式版本控制系统的方法:一个方法

  • 不一定需要单个命令
  • 适用于任何一种著名的分布式版本控制系统
  • 让 dvcs 认为它​​们是分支:/official/{0​​.1,0.2} 树、/variantA/trunk 树、...
  • 让 dvcs 了解这些树的继承关系
有帮助吗?

解决方案

如果你考虑 git 作为可能的 DVCS 候选者,ruby 脚本 svn2git 做你需要的。

问题中的更多详细信息: 使用 Git-Svn 克隆非标准 Svn 存储库

其他提示

Mercurial 附带了一个转换扩展,它应该可以满足您的需求。请参阅 转换 Mercurial 网站上的扩展详细信息。

对于 Git,请参阅以下位置的说明: http://github.com/guides/import-from-subversion

上次我手动执行此操作时,我使用了以下命令。(这是一个不使用标签或分支的项目。使用 svn2git 如果您有标签或分支,可能会产生比 git-svn 更好的结果。)

cat "mysvnusername = Me Myself <me.myself@somewhere.com>" >> authors.txt

svnserve --daemon --foreground --root <SVN-REPO-PARENT-DIR>
git svn clone --stdlayout --authors-file=authors.txt --no-metadata svn://localhost/<SVN-REPO-NAME>

# push to a public repo and clone from there, to get push/pull working easily
cd <SVN-REPO-NAME>
git remote add origin git@github.com:mygithubusername/<GIT-REPO-NAME>.git
git push origin master
cd ..
rm -rf <SVN-REPO-NAME>

git clone git@github.com:mygithubusername/<GIT-REPO-NAME>.git

但由于您有非标准 SVN 存储库布局,因此您需要指定 --trunk、--tags 和 --branches 参数,而不是 --stdlayout git svn 克隆.

为了表示存储库的整个继承历史,您可以尝试重新排序存储库,以便您拥有标准的平面存储库布局,而不是非标准层次结构:

/branches/original-0.1
/branches/original-0.2
/branches/variantA-trunk
/branches/variantA-who-branch_for_xxx
/branches/variantA-she-branch_for_yyy
/branches/variantB-trunk
/branches/variantB-who-branch_for_zzz
...

这将使导入工具更容易理解存储库。然后,当它们被导入后,您可以在新存储库中更好地重新组织它们。

另外,我听说 Git 1.6.x 支持深度克隆,这样你就可以给 git svn clone 参数如 --branches=branches/*/* 这将深入查看分支的层次结构。看 这个帖子 获取使用它的示例。

$ bzr svn-import --layout trunk1 svn-root-url bzr.repo

应该做正确的事。您需要安装 bzr-svn 插件才能执行此操作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top