简体   繁体   English

人们如何管理存储在多个(Mercurial)存储库中的公共库文件的更改?

[英]How do people manage changes to common library files stored across mutiple (Mercurial) repositories?

This is perhaps not a question unique to Mercurial, but that's the SCM that I've been using most lately. 这可能不是Mercurial特有的问题,但那是我最近一直在使用的SCM。

I work on multiple projects and tend to copy source code for libraries or utilities from a previous project to get a leg up on starting a new project. 我从事多个项目,并倾向于从以前的项目中复制库或实用程序的源代码,以便开始一个新项目。 The problem comes in when I want to merge all the changes I made in my latest project, back into a "master" copy of those shared library files. 当我想将我在最新项目中所做的所有更改合并到这些共享库文件的“主”副本中时,问题就出现了。

Since the files stored in disjoint repositories will have distinct version histories, Mercurial won't be able to perform an intelligent merge if I just copy the files back to the master repo (or even between two independent projects). 由于存储在不相连的存储库中的文件将具有不同的版本历史记录,如果我只是将文件复制回主存储库(甚至两个独立的项目之间),Mercurial将无法执行智能合并。

I'm looking for an easy way to preserve the change history so I can merge library files back to the master with a minimum of external record keeping (which is one of the reasons I'm using SVN less as merges require remembering when copies were made across branches). 我正在寻找一种简单的方法来保存更改历史记录,这样我就可以将库文件合并到主服务器上并保留最少的外部记录(这是我使用SVN的原因之一,因为合并需要记住复制时跨越分支机构)。

Perhaps I need to do a bit more up-front organization of my repository to prepare for a future merge back to a common master. 也许我需要对我的存储库做一些更多的前期组织,以便为将来的合并做准备回到一个共同的主人。

Three solutions, pick your favorite: 三种解决方案,选择你喜欢的:

  1. Put all projects into one repository. 将所有项目放入一个存储库。
  2. Make a separate repository for shared code and different repository for each project. 为每个项目为共享代码和不同存储库创建单独的存储库。
  3. One repository with Subrepositories: https://www.mercurial-scm.org/wiki/subrepos , keep all common code in one subrepo and different subrepos for each project. 一个存储库与子存储库: https ://www.mercurial-scm.org/wiki/subrepos,将所有公共代码保存在一个子项目和每个项目的不同子库中。

Copying actual files between repositories with no common ancestors will never be optimal as history is not preserved. 在没有共同祖先的存储库之间复制实际文件将永远不会是最佳的,因为不保留历史记录。

I'd recommend against your "copy the sourcecode" practice but use binary distribution for your custom libraries instead. 我建议不要使用“复制源代码”练习,而是使用二进制分发代替自定义库。 These binaries are checked in along the sourcecode. 这些二进制文件沿源代码签入。

  • reduces build-time 减少构建时间
  • no overhead of tracking changes in all copies of the library 没有跟踪库的所有副本中的更改的开销
  • you can use different versions of the same library in different projects. 您可以在不同的项目中使用同一个库的不同版本。

EDIT: And for the issue with "common" or "toolbox" libaries in general, read this post from ayende. 编辑:对于“普通”或“工具箱”库的问题,请阅读ayende的这篇文章

使用移植扩展

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM