在 Mercurial 中,它“安全”吗?应用 mq 补丁时拉取?

发布于 2024-10-19 23:29:56 字数 228 浏览 2 评论 0原文

go 编程语言有一个关于使用 mq 进行代码审查的页面,它指出:“自从拉动、推送以来,在应用 mq 补丁时更新和提交可能会损坏您的存储库”。

我理解为什么推送或更新可能是一个问题,但是拉动也是一个问题吗?

如果您应用了 mq 补丁并拉取,您的存储库是否会损坏?

The go programming language has a page on code reviews using mq and it states: "Since pulling, pushing, updating and committing while mq patches are applied can damage your repository".

I understand why pushing or updating could be an issue, but is pulling an issue?

If you have mq patches applied and you pull will your repository be damaged?

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

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

发布评论

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

评论(2

〃安静 2024-10-26 23:29:56

如果您应用了 mq 补丁并拉取,您的存储库是否会损坏?

答案是。当您拉取时,您可以将更多变更集添加到本地历史记录中。应用的 MQ 补丁也作为变更集存在于变更集图中,但这并不危险,您不会丢失任何数据。

可能发生的是您已经应用了一些补丁:

.... a --- b --- p1 --- p2 --- p3

然后您将这些补丁发送到上游邮件列表以供包含。有人审查补丁、提交补丁,并将变更集推送到主存储库。之后会推送其他变更集,下次拉取时,您最终会得到:

.... a --- b --- p1 --- p2 --- p3 --- c --- d

变更集 p1p3 仍然是存储库中的 MQ 补丁,但它们现在有非 - MQ 孩子们!尝试弹出它们会导致(使用 Mercurial 2.1.1):

$ hg qpop
abort: popping would remove a revision not managed by this patch queue

这有点僵局。这很烦人,但并不危险。要解决此问题,您必须让 MQ 了解 p1p3 不再由 MQ 管理。您可以通过从 .hg/patches/status 中删除这些变更集的行来完成此操作。当这种情况发生时,MQ 最终可能会自行删除这些行 - 但这种情况很少发生,因此还没有人编写该补丁。

If you have mq patches applied and you pull will your repository be damaged?

The answer is no. When you pull, you add more changesets to your local history. The applied MQ patches also live as changesets in the changeset graph, but that's not dangerous and you will not lose any data.

What may happen is that you have applied some patches:

.... a --- b --- p1 --- p2 --- p3

You then send the patches to the upstream mailinglist for inclusion. Someone reviews the patches, commits them, and pushes the changesets to the main repository. Other changesets are pushed afterwards and next time you pull you end up with:

.... a --- b --- p1 --- p2 --- p3 --- c --- d

Changesets p1 to p3 are still MQ patches in your repository, but they now have non-MQ children! Trying to pop them results in (with Mercurial 2.1.1):

$ hg qpop
abort: popping would remove a revision not managed by this patch queue

This is a bit of a dead-lock. It's annoying but not dangerous. To resolve it you must make MQ understand that p1 to p3 are no longer managed by MQ. You do this by removing the lines for these changesets from .hg/patches/status. MQ should probably eventually remove these lines by itself when this happens — but it happens pretty rarely so nobody has written that patch yet.

残月升风 2024-10-26 23:29:56

如果您在存储库中应用了 MQ 补丁时意外地与上游变更集合并,这肯定会成为一个问题。这是我刚刚尝试过的一个场景,它似乎出现了问题:

  • 假设在您的克隆中,您使用 hg qpush -a 推送所有补丁,
  • 然后使用 hg pull 从上游拉取变更集code> (但不要 hg update)。这将创建一个新分支(hg Heads 将您所在的分支显示为 qtip
  • 将 您刚刚拉取的新分支显示为 tip)正在黑客攻击,您决定切换到新分支,并运行 hg update -C Tip,但这样做弹出补丁。
  • 当您进行更多修改时,您决定使用 hg merge 合并分支。哎呀!您刚刚合并了一个从未qfinished 的 MQ 补丁。

由于 MQ 通过创建和销毁历史记录来工作,因此补丁变更集看起来就像历史记录的正常部分。但是,由于您“跳过”了已应用的补丁并将它们与补丁变更集合并,因此您无法再弹出补丁。事实上,运行 hg qpop 将中止并显示一条消息:

abort: popping would remove a revision not managed by this patch queue

当我使用补丁队列时,我通常只是尝试小心并有意识地拉或推,但是 go 建议的钩子页面提供了很好的保障。

请注意,您始终可以在上游变更集之上重新调整补丁的基础。有关如何执行此操作的说明,请参阅此页面

It can certainly be an issue if you accidentally merge with the upstream changesets while you have MQ patches applied in your repository. Here's a scenario I just tried out which seems to exhibit problems:

  • suppose in your clone, you push all of your patches with hg qpush -a
  • then you pull changesets from upstream with hg pull (but don't hg update). this creates a new branch (hg heads shows the branch you're on as qtip and the new branch you just pulled as tip)
  • as you're hacking away, you decide to switch over to the new branch, and run hg update -C tip, but do so without popping your patches.
  • as you hack away some more, you decide to merge the branches with hg merge. Oops! You just merged in an MQ patch that was never qfinished.

Since MQ works by creating and destroying history, the patch changesets look like normal parts of the history. However, since you "leap-frogged" over the applied patches and merged them with a non-patch changeset, you can no longer pop the patches off. In fact, running hg qpop will abort with a message saying:

abort: popping would remove a revision not managed by this patch queue

I generally just try to be careful and conscious about pulling or pushing when I'm working with a patch queue, but the hooks suggested by the go page provide a nice safeguard.

Note that you can always rebase your patches on top of upstream changesets as well. See this page for a description of how to do that.

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