使用Mercurial (Hg),签入rev 100、101和102后,是否需要将它们一一删除?

发布于 2024-10-10 08:58:32 字数 145 浏览 0 评论 0原文

将代码简化为最简单的形式后,如修订版100、101、然后102,当发现问题时,是否可以

hg backout -r 100

取消所有更改?或者我们是否需要取消 102、101,然后取消 100(即一一取消)?

After reducing the code to the simplest form, as revision 100, 101, and then 102, when the problem is found, can an

hg backout -r 100

be done to back all changes out? Or do we need to backout 102, 101, and then 100 (ie, one by one)?

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

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

发布评论

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

评论(6

独留℉清风醉 2024-10-17 08:58:32

您的命令不会执行您想要的操作——回退仅执行单个变更集。

然而,有很多方法可以撤销三个连续的变更集,这实际上完全取决于您想要在历史图中留下什么。

最快的方法是:

hg diff -r 102 -r 99 | hg import --no-commit -

“取 102 和 99 之间的差异(注意相反的顺序)并将其作为补丁应用。之后,您将检查工作目录,如果您愿意,请执行 hg 情况

缺点是您的历史图表将如下所示:

--[99]---[100]---[101]---[102]---[103]

其中 103 是 100、101 和 102 组合更改的负数。这并不能显示真正发生的

。到 hg update 99 进行提交,任何提交,所以现在您的历史记录如下所示:

--[99]---[100]---[101]---[102]
     \
      [103]---

然后执行 hg --config ui.merge=internal:local merge 102 合并将 102 更改为 103,但不会对 100、101、102 进行任何更改。

这将使您的历史记录看起来像:

--[99]---[100]---[101]---[102]
     \                       \
      [103]-------------------[104]

这对我来说更清楚地说明了发生了什么,

或者您可能只是这样做:

hg backout 102
hg backout 101
hg backout 100

这使您的历史记录。 :

--[99]---[100]---[101]---[102]---[103]---[104]---[105]

其中 103、104 和 105 分别是 102、101 和 100 的倒数,但这很愚蠢。

Your command won't do what you want -- backout does only a single changeset.

There are, however, quite a few ways to backout three contiguous changesets, and it really all depends what you want left in your history graph.

The quickest way would be:

hg diff -r 102 -r 99 | hg import --no-commit -

which says "take the difference between 102 and 99 (notice the reversed order) and apply it as a patch. After that you'd check out the working directory and if you like it do a hg commit --addremove.

The drawback there is that your history graph will look like:

--[99]---[100]---[101]---[102]---[103]

Where 103 is the negative of the combined changed of 100, 101, and 102. That doesn't show what really happened.

Better would be to hg update 99 do a commit, any commit, so now your history looks like:

--[99]---[100]---[101]---[102]
     \
      [103]---

and then do hg --config ui.merge=internal:local merge 102 which merged 102 into 103 and but takes none of the changes from 100, 101, 102.

That will leave your history looking like:

--[99]---[100]---[101]---[102]
     \                       \
      [103]-------------------[104]

which to me more clearly says what happened. Either works, though.

Or you could probably just do:

hg backout 102
hg backout 101
hg backout 100

which makes your history:

--[99]---[100]---[101]---[102]---[103]---[104]---[105]

Where 103, 104, and 105, are the inverses of 102, 101, and 100, respectively, but that's just silly.

青春有你 2024-10-17 08:58:32

假设您不再需要转速 100、101 或 102 中的任何内容,Ry4an 的第二个建议的类似答案如下:

  • 从提示中,使用 hg commit --close-branch - 这会删除分支从头目列表中告诉世界,实际上,我不会再在此基础上进行开发。 (这对应于下图中的提交 103)
  • 更新到最后一个好的版本(hg update 99),继续正常工作,并进行新的提交(下图中的提交 104、105

)结果图如下所示:

--[99]---[100]---[101]---[102]---[103]---X
     \                       
      [104]---[105]---...

细微的区别是没有“假合并”(您仅从一个父级获取更改)。

Assuming you no longer want anything from revs 100, 101, or 102, a similar answer to Ry4an's second suggestion is the following:

  • From the tip, use hg commit --close-branch - this removes the branch from the list of heads and tells the world, in effect, I'm not going to develop on top of this anymore. (This corresponds to commit 103 in the below graph)
  • Update to the last good revision (hg update 99), continue work as normal, and make new commits (commit 104, 105 in the below graph)

The resulting graph appears like:

--[99]---[100]---[101]---[102]---[103]---X
     \                       
      [104]---[105]---...

The subtle difference is that there is no "fake merge" (where you take only the changes from one parent).

你げ笑在眉眼 2024-10-17 08:58:32

您需要单独撤销它们,因为撤销只会删除您撤销的变更集的更改。

请参阅

http://hgbook.red-bean.com/read/寻找和修复错误.html

You need to back them out individually as backout only removes the changes for the changeset that you backout.

See

http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html

葬心 2024-10-17 08:58:32

来自 http://hgbook.red-bean.com/read /finding-and-fixing-mistakes.html

hg backout 命令采用单个变更集 ID 作为其参数;这是要退出的变更集。

alt text

至少从上面的信息来看,只需要一个变更集就可以退出。

From http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html:

The hg backout command takes a single changeset ID as its argument; this is the changeset to back out.

alt text

At least from the information above, it takes only a single changeset to back out.

五里雾 2024-10-17 08:58:32

一种方法是 hg up -r mygoodandawesomerev,然后针对该方法进行提交,本质上创建一个在微风中摇曳的未命名分支。

One approach is hg up -r mygoodandawesomerev, then commit against that, creating, in essence, an unnamed branch waving in the breeze.

雪花飘飘的天空 2024-10-17 08:58:32

您是否真的想要取消不良变更集,以便继续从变更集 99 开始工作,但您在历史记录中看到了 100 - 102?

或者你想彻底摆脱它们(让它们从历史中消失)?
如果是,您可以克隆存储库,但排除不良更改集:

Mercurial:修复 borked 历史记录

Do you really want to back out the bad changesets, so that you continue working from changeset 99, but you see 100 - 102 in the history?

Or do you want to completely get rid of them (so that they even disappear from the history)?
If yes, you can just clone the repository, but exclude the bad changesets:

Mercurial: Fix a borked history

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