简体   繁体   English

如何防止分散的水银分支合并?

[英]How to prevent divergent mercurial branches from merging?

I have a project stored in mercurial which has grown well beyond its original remit, and now I want to split the repository into two separate projects. 我有一个存储在Mercurial中的项目,其规模已远远超出其最初的职权范围,现在我想将存储库分为两个单独的项目。 Say the file tree looks something like this: 说文件树看起来像这样:

src/
  a/
    a.h
    a.c
  b/
    b.h
    b.c

Say I've hg clone d this repository twice, and in the first clone I've performed an hg rm src/b/* , and in the second I've performed an hg rm src/a/* . 假设我已经两次hg clone这个存储库,在第一个克隆中我执行了hg rm src/b/* ,在第二个克隆中我执行了hg rm src/a/* This gives me the two separate source trees I want, with history and revision numbering preserved in each branch. 这给了我想要的两个独立的源树,每个分支中都保留了历史记录和修订版编号。

The problem I now have is what happens if, in the future, I ever accidentally pull from the a/ clone into the b/ clone. 我现在遇到的问题是,如果将来我不小心将a /克隆拖入b /克隆,将会发生什么情况。 What I'd like is for mercurial to simply refuse to pull from, or push to, the other branch, if I ever try to do so, as if the two had never shared history. 我想要的是,如果我尝试这样做,Mercurial只会拒绝从另一个分支中拉出或推入另一个分支,就好像两者从未共享过历史一样。

Is this possible? 这可能吗? If not, is there a canonical way to create two parallel projects from one original which preserves history and revision numbering? 如果不是,是否有一种规范的方法可以从一个原始文件创建两个并行项目,从而保留历史记录和修订版编号?

The canonical way would be to use hg convert with a filemap like this: 规范的方法是将hg convert与以下文件映射一起使用:

exclude b
rename a .

(and afterwards with the roles of a and b reversed to create the second repository) (然后将ab的角色互换以创建第二个存储库)

This way you end up with two unrelated repositories (which Mercurial will refuse to push/pull without the use of force) only containing the history of a single directory. 这样,您最终得到两个不相关的存储库(Mercurial将在不使用武力的情况下拒绝推/拉),它们仅包含单个目录的历史记录。

Also see this question for reference. 另请参阅问题以供参考。

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

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