从“hg update"中恢复带有未提交的更改 [英] Recover from "hg update" with uncommitted changes

查看:44
本文介绍了从“hg update"中恢复带有未提交的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Mercurial 时遇到以下问题,这很烦人:

I run into the following issue all the time with Mercurial, and it's very annoying:

  • 我正在修订 A.
  • 我有本地更改,我打算在 A 之上提交或修改,但还没有.
  • 我想去一些修订版 B,但我忘了我有本地更改!
  • 我做hg update B.Mercurial有帮助地"尝试重新调整我的本地更改以应用于 B 之上.这通常会导致冲突,现在它要求我修复冲突.
  • I'm at some revision A.
  • I have local changes, which I meant to commit or amend on top of A, but haven't yet.
  • I want to go to some revision B, but I forgot that I had local changes!
  • I do hg update B. Mercurial "helpfully" tries to rebase my local changes to apply on top of B. This typically results in conflicts, and it now asks me to fix the conflicts.

但是,我不想解决冲突!我根本不希望我的本地更改应用于 B 之上.我希望它们留在 A,或者作为 A 之后的新提交,或者根据情况修改为 A.

However, I don't want to fix the conflicts! I don't want my local changes to apply on top of B at all. I want them to stay at A, either as a new commit just after A, or amended into A, as the case may be.

有没有办法从这种状态中恢复过来?我知道的唯一方法是

  1. 修复 B 处的合并冲突
  2. 回到A,再次发生合并冲突
  3. 再次修复 A 处的合并冲突
  4. 在 A 提交我的更改并返回到 B

这是很多工作,而且毫无意义.我不应该重新调整我的本地更改以应用于 B 之上,只需再次重新调整它们以应用于 A 之上.

This is a lot of work, and it's pointless. I shouldn't have to rebase my local changes to apply on top of B, only to rebase them again to apply on top of A.

如果没有更好的方法从这个错误中恢复过来,有没有办法hg在你有本地更改时拒绝更新?我从不想这样做 - 如果我想要,我只需提交本地更改并将它们重新绑定到 B 之上.

If there's no better way to recover from this mistake, is there a way to get hg to refuse to do an update when you have local changes? I never want to do that - if I wanted that I'd just commit the local changes and rebase them on top of B.

推荐答案

在某处更新后取回脏文件有点棘手.技巧"是确保您的工作副本在第一次更新后具有脏文件.

Getting the dirty files back after updating somewhere and back is a bit tricky. The "trick" is to make sure that your working copy has the dirty files after the first update.

所以在你做完之后

hg update $SOMEWHERE

发现乱码,因为Mercurial开始打开合并工具,冷静关闭合并工具然后运行

and discover the mess because Mercurial begins opening merge tools, calmly close the merge tools and then run

hg resolve --unmark --all
hg resolve --all --tool internal:local

由于您对它们进行了更改而合并的所有文件现在看起来就像它们在脏工作副本中所做的一样.这包括完全合并的文件和系统提示您合并的文件.现在可以更新回来:

All files that were merged because you had changes in them will now look like they did in your dirty working copy. This includes files that were merged cleanly and files you were prompted to merge. Updating back is now possible:

hg update $BACK
hg resolve --unmark --all
hg resolve --all --tool internal:local

您现在应该回到起点.如果您在第一次更新后修改了文件,那么它就是您在第二次解析后看到的修改后的版本.这就是您希望在第一次更新后解析文件的原因.

You should now be back to where you started. If you modified the files after the first update, then it is the modified version you see after the second resolve. This is why you will want to resolve the files after the first update.

这篇关于从“hg update"中恢复带有未提交的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆