Mercurial:恢复单个大块
如何在 Mercurial 中恢复单个块,类似于在 darcs 中完成的方式,即它询问我每个块和文件是否要恢复它? 可以使用 TortoiseHg 吗?
谢谢
How do I revert a single hunk in Mercurial, similar to the way it's done in darcs, i.e. it asks me for each hunk and file whether I want to revert it? Is it possible using TortoiseHg?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,mercurial 指的是“块”,至少在 Shelve 工具中是这样。 这让我想到了恢复它们的最喜欢的方式(以及 TortoiseHg 最喜欢的功能)。
只需将您想要恢复的块移至您仅为了删除目的而创建的架子上即可。 只要按照您需要的方式识别块,这种方法就非常有效。 如果没有,您别无选择,只能手动执行某些操作。
如果您使用 TortoiseHg Workbench 或 VisualHg,则可以很容易地使用 Shelve 工具:diff 模式切换按钮旁边有一个按钮。 如果您不熟悉架子,请帮自己一个忙并开始使用它。 当我忘记提前提交或决定从提交中删除实验代码时,它让我省去了很多麻烦。
Actually mercurial refers to "chunks", at least in the Shelve tool. Which brings me to favorite way to revert them (and favorite features of TortoiseHg).
Just move the chunks you want to revert onto a shelf you create solely with the intention to delete. This works really well as long as the chunks are identified as you need them to be. If not, you've got no choice but to do something manually.
If you use TortoiseHg Workbench or VisualHg, it is very easy to get to the Shelve tool: there is a button next to the diff mode toggle buttons. If you are not familiar with shelves, do yourself a favor and start using it. It has saved me much aggravation when I've forgotton to commit early, or decided to leave out experimental code from a commit.
record
扩展 的灵感来自darcs record. 它将允许您仅添加特定的块到下一次提交,即与您想要的相反。 但是您可以添加除要还原的那个之外的所有帅哥,然后执行
hg revert
来还原它。 有点倒退,我知道......:-)你也可以做
hg diff > 修补; hg revert
,编辑patch
以删除该块并执行hg import --no-commit
重新应用补丁。 这可能会更快,但需要您手动编辑补丁。 我在 Emacsdiff-mode
方面取得了巨大成功,但既然您询问了 TortoiseHg,您可能不想使用 Emacs。The
record
extension is inspired bydarcs record
. It will allow you to add only specific hunks to the next commit, i.e., the opposite of what you want. But you could add all hunks except the one you want to revert and then do ahg revert
to revert it. A little backwards, I know... :-)You could also do
hg diff > patch; hg revert
, editpatch
to delete the hunk and dohg import --no-commit
to reappy the patch. That is likely faster, but requires you to manually edit the patch. I've had great success with the Emacsdiff-mode
, but since you ask about TortoiseHg you might not want to use Emacs.要反转单个文件上的变更集,请尝试:
这将反转该文件名上的修订版引入的变更集。 现在,如果相同的 darcs/git 风格的樱桃采摘行为可以包含在其中,我会非常高兴。
For reversing a changeset on a single file try:
That will reverse the changeset introduced by that revision on that filename. Now if the same darcs/git style cherry-picking behavior could be included in that somehow I would be very happy.