确保分支之间的合并发生在一个方向

发布于 2024-11-06 18:27:01 字数 127 浏览 1 评论 0原文

今天早上,我发现我的同事在 Mercurial 的两个分支之间合并了错误的方式——我们有一个 ver5 和 ver6 分支,在 ver6 中有额外的文件。有没有什么方法(可能是服务器端挂钩)强制任何 ver5 节点的子节点都来自 ver5?

This morning I discovered that my co-worker had merged the wrong way between two branches in mercurial --we have a ver5 and ver6 branch, with extra files in ver6. Is there any way (a serverside hook probably) to enforce that the children of any ver5 node be from ver5?

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

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

发布评论

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

评论(3

笛声青案梦长安 2024-11-13 18:27:01

无论您将 ver5 合并到 ver6 还是将 ver6 合并到 ver5,您最终都会得到一个包含 ver6 内容的 ver5 的子版本。

但是,如果您想避免分支名称为 ver5 的变更集具有 ver6 的祖先,您可以使用钩子轻松做到这一点。棘手的部分就是把钩子放在哪里。如果您将其设为 pretxnchangegroup 挂钩,则可以防止人们将有问题的合并推送到服务器端存储库中,但他们已经提交了该合并,并且可能在此基础上进行了更多更改,并且他们将很难弄清楚如何解决它。如果您可以控制他们的本地设置,您可以放入一个 pretxncommit 挂钩来阻止他们提交合并,但您不能让他们仅使用 Mercurial 工具运行该挂钩。

实际的钩子,无论您使用哪种类型,都可以使用以下策略之一:

  • 检查分支名称是否为 ver5,如果是,请确保 ver6 中没有特定文件/内容是 presnet

,或者

  • 检查分支名称是否为 ver6,如果是,请确保不是 p1 p2 也没有分支名称 ver5

TL;DR:这可能比它的价值更麻烦——坚持羞辱。

Whether you have ver5 merged into ver6 or ver6 merged into ver5 you're still ending up with a child of ver5 that has stuff from ver6 in it.

If, however, you want to avoid a changeset whose branch name is ver5 having ancestors that are ver6 you could do that pretty easily with a hook. Just where you put that hook is the tricky part. If you make it a pretxnchangegroup hook you can prevent people from pushing an offending merge into the server-side repo, but they will have already committed it, and maybe some more changes on top of it, and they'll have a hard time figuring out what to do to fix it. If you can control their local setups you can put in a pretxncommit hook that prevents them from committing the merge, but you can't make them run that hook using only Mercurial tools.

The actual hook, whichever type you make it, could use either of these strategies:

  • check if the branchname is ver5 and if so make sure no specific file/content from ver6 is presnet

or

  • check if branchname is ver6 and if so make sure neither p1 nor p2 has branchname ver5

TL;DR: It's probably more trouble than it's worth -- stick to shaming.

夜深人未静 2024-11-13 18:27:01

我对“Mercurial:允许从发布分支合并到默认分支,但反之亦然”的回答是否有帮助,而不是发布两次? https://stackoverflow.com/a/19926324/1025457

Rather than post twice, would my answer to "Mercurial: allow merge from a release branch to the default one, but not vice versa" help? https://stackoverflow.com/a/19926324/1025457

送你一个梦 2024-11-13 18:27:01

这应该可以做到。它使用 revset 查询 查找任何与 ver5 的合并来自ver6

hg log -r 'children(p2(::ver5 and ::ver6 and merge()) and branch(ver6)) and branch(ver5)'
  • ::ver5 和 ::ver6 以及 merge() 查找作为 ver5ver6 分支的祖先的所有合并
  • p2(. ..) 和branch(ver6) 获取ver6 分支上的第二个父级(传入变更集)。
  • 然后,children(...) 和branch(ver5) 获取ver5 分支上的实际合并变更集。

我最近需要自己解决这个问题,但也需要确保< code>default 没有间接合并到我的发布分支中,即 default ->功能->发布。

This should do it. It uses a revset query to find any merges into ver5 from ver6.

hg log -r 'children(p2(::ver5 and ::ver6 and merge()) and branch(ver6)) and branch(ver5)'
  • ::ver5 and ::ver6 and merge() finds all merges that are ancestors of both ver5 and ver6 branches
  • p2(...) and branch(ver6) grabs the second parent (incoming changeset) that are on the ver6 branch.
  • children(...) and branch(ver5) then grabs the actual merge changeset that is on the ver5 branch.

I recently needed to figure this out myself, but also needed to ensure that default wasn't indirectly merged into my release branch, i.e. default -> feature -> release.

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