确保分支之间的合并发生在一个方向
今天早上,我发现我的同事在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无论您将 ver5 合并到 ver6 还是将 ver6 合并到 ver5,您最终都会得到一个包含 ver6 内容的 ver5 的子版本。
但是,如果您想避免分支名称为 ver5 的变更集具有 ver6 的祖先,您可以使用钩子轻松做到这一点。棘手的部分就是把钩子放在哪里。如果您将其设为 pretxnchangegroup 挂钩,则可以防止人们将有问题的合并推送到服务器端存储库中,但他们已经提交了该合并,并且可能在此基础上进行了更多更改,并且他们将很难弄清楚如何解决它。如果您可以控制他们的本地设置,您可以放入一个
pretxncommit
挂钩来阻止他们提交合并,但您不能让他们仅使用 Mercurial 工具运行该挂钩。实际的钩子,无论您使用哪种类型,都可以使用以下策略之一:
,或者
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 apretxncommit
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:
or
TL;DR: It's probably more trouble than it's worth -- stick to shaming.
我对“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
这应该可以做到。它使用 revset 查询 查找任何与
ver5
的合并来自ver6
。::ver5 和 ::ver6 以及 merge()
查找作为ver5
和ver6
分支的祖先的所有合并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
fromver6
.::ver5 and ::ver6 and merge()
finds all merges that are ancestors of bothver5
andver6
branchesp2(...) and branch(ver6)
grabs the second parent (incoming changeset) that are on thever6
branch.children(...) and branch(ver5)
then grabs the actual merge changeset that is on thever5
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.