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

发布于 2024-12-01 09:44:17 字数 488 浏览 3 评论 0原文

我有一个存储在 Mercurial 中的项目,该项目已经远远超出了其最初的职责范围,现在我想将存储库拆分为两个单独的项目。假设文件树看起来像这样:

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

假设我已经 hg cloned 这个存储库两次,并且在第一次克隆中我执行了 hg rm src/b/*,第二次我执行了 hg rm src/a/*。这为我提供了我想要的两个独立的源代码树,每个分支中都保留了历史记录和修订编号。

我现在遇到的问题是,如果将来我不小心从 a/ 克隆拉入 b/ 克隆,会发生什么。我希望 Mercurial 能够简单地拒绝从另一个分支拉出或推送到另一个分支(如果我尝试这样做),就好像两者从未共享过历史一样。

这可能吗?如果没有,是否有一种规范的方法可以从一个原始项目创建两个并行项目,从而保留历史记录和修订编号?

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. Say the file tree looks something like this:

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

Say I've hg cloned 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/*. 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. 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.

Is this possible? If not, is there a canonical way to create two parallel projects from one original which preserves history and revision numbering?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2024-12-08 09:44:17

规范的方法是使用 hg Convert 与这样的文件映射:(

exclude b
rename a .

然后使用ab 的角色颠倒以创建第二个存储库)

这样您最终会得到两个不相关的存储库(Mercurial 将拒绝在不使用强制的情况下推/拉)仅包含单个目录的历史记录。

另请参阅问题以供参考。

The canonical way would be to use hg convert with a filemap like this:

exclude b
rename a .

(and afterwards with the roles of a and b reversed to create the second repository)

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.

Also see this question for reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文