Subversion 存储库布局
大多数 Subversion 工具都会使用 /trunk、/branches 和 /tags 创建默认存储库布局。该文档还建议不要为每个项目使用单独的存储库,以便可以更轻松地共享代码。
遵循这个建议,我拥有了一个具有以下布局的存储库:
/trunk /Project1 /Project2 /branches /Project1 /Project2 /tags /Project1 /Project2
等等,你就明白了。随着时间的推移,我发现这种结构有点笨拙,我想到这些建议还有另一种解释,例如:
/Project1 /trunk /branches /tags /Project2 /trunk /branches /tags
那么,人们使用哪种布局,为什么?或者 - 有另一种方法可以做我完全错过的事情吗?
Most subversion tools create a default repository layout with /trunk, /branches and /tags. The documentation also recommends not using separate repositories for each project, so that code can be more easily shared.
Following that advice has led to me having a repository with the following layout:
/trunk /Project1 /Project2 /branches /Project1 /Project2 /tags /Project1 /Project2
and so on, you get the idea. Over time, I've found this structure a bit clumsy and it occurred to me that there's an alternative interpretation of the recommendations, such as:
/Project1 /trunk /branches /tags /Project2 /trunk /branches /tags
So, which layout do people use, and why? Or - is there another way to do things that I've completely missed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我决定硬着头皮重组我的存储库。我写了一个小程序来提供帮助(如下)。我遵循的步骤是:
svn checkout
整个存储库。这花费了很长的时间和大量的磁盘空间。svn delete
过时的主干、标签和分支 文件夹)svn commit
返回到存储库。整个过程需要时间,但我决定采用这种方法,因为修改工作副本比破解实时存储库要安全得多,而且我可以选择在出现问题时简单地丢弃工作副本来解决任何问题在工作副本中并将整个重组作为单个修订提交。
这是我用来进行移动的 C# 代码。需要 SharpSvn 库。
I decided to bite the bullet and restructure my repository. I wrote a small program to assist (below). The steps I followed were:
svn checkout
the entire repository. This took a long time and a lot of disk space.svn delete
the obsolete trunk, tags and branches folders)svn commit
back to the repository.This whole process took time, but I decided to take this approach because modifying a working copy is a lot safer than hacking up a live repository and I had the options to simply throw away the working copy if it all went wrong, to fix any issue in the working copy and commit the entire restructure as a single revision.
Here's the C# code I used to do the moving. Requires SharpSvn library.
请参阅 存储库布局 来自 svnbook
Refer Repository Layout from the svnbook
我发现 Subversion 存储库布局 博客文章很好地总结了这一点:
因此,换句话来说:
整篇文章值得一读。
I find that the Subversion Repository Layout blog post summarizes this pretty well:
So, to paraphrase:
The whole post is worth the read.
第二种布局是要走的路。一个很好的理由是允许或拒绝开发人员参与其中一个项目。
The second layout is the way to go. One good reason is to allow or deny a developer to work with one of the projects.
我更喜欢第二个。对于第二种,如果两个项目之间的人员权限不同,则更容易实现。
I prefer the second. With the second, if people's permissions are different between the two projects, it's easier to implement.
我非常喜欢第二种,如果需要的话,使用 maven 或 ant/ivy 从其他项目中获取工件。
我还喜欢每个存储库有一个项目,或少量相关的存储库。
它简化了访问控制,在存储库级别比存储库内的路径级别更容易 - 特别是在针对 LDAP 进行身份验证时。
备份/恢复操作一开始有点复杂,因为您必须循环遍历所有存储库才能进行热复制,但万一不幸,您只需恢复一个存储库 - 其他存储库不需要脱机或丢失任何数据。当项目终止时,可以简单地删除存储库,从而节省您未来备份的空间。
当每个存储库只有一个项目(或少量相关项目)时,挂钩脚本会变得更简单,您无需检查受影响的路径即可在挂钩中有条件地采取操作。
正如 retracile 所指出的,如果您想使用 svndumpfilter 有选择地导出,那么一个整体存储库可能会是一个巨大的痛苦 - 导致它死亡的更改路径的数量可能会很高。
为未来版本的 svn 升级存储库模式需要更多的努力 - 您必须执行n次而不是一次...但是它可以编写脚本,并且您不需要立即协调每个人。
如果有人提交了密码,而您必须删除它,您可以在一个存储库中快速进行转储/过滤/重新加载,同时不会影响其他团队。
如果您走这条路,有一个建议 - 每个存储库都有一个不同的 .conf 文件,而不是一个巨大的文件,同样,它更容易管理,并且可以让您放心,某些时间戳将会过时 - 如果出现问题,您可以查找最近的变化更容易。
I greatly prefer the second, using maven or ant/ivy to ingest the artifacts from other projects if needed.
I also prefer to have a single project per repository, or a small number of related repositories.
It simplifies access control, which is easier at the repository level than the path level within the repository - particularly when authenticating against LDAP.
Backup/restore operations are a little more complicated initially as you have to loop through all the repositories to do a hot copy, but in the unlucky event you have to restore only one repo - the others needn't be taken offline or loose any data. As projects die, the repositories can simply be deleted thus saving you space on future backups.
Hook scripts become simpler when there is only one project (or a small number of related projects) per repository, you don't have to examine the affected path to conditionally take action in your hook.
As retracile noted, one monolithic repository is likely going to be a huge pain if you ever want to selectively export using svndumpfilter - the number of changed paths causing it to die is likely to be high.
Upgrading the repository schema for future versions of svn requires more effort - you have to do it n times rather than once... but it can be scripted and you needn't coordinate everyone at once.
If someone commits a password, and you have to obliterate it, you can do the dump/filter/reload quickly in one repo while not affecting other teams.
One piece of advice if you go this route - have a different .conf file per repo rather than one huge one, again it's easier to manage as well as providing comfort that some timestamps are going to be old - if something's amiss you can look for recent changes easier.