在 Mercurial 中,为什么当有其他修改的文件时我们无法撤销提交?
昨天我提交了一个文件,然后想要 hg 撤销,但是 Mercurial 说无法撤销,因为我在项目中还有其他修改过的文件……
这有点奇怪……每个文件都不是原子级别的?提交 1 个文件然后撤消 1 个文件?
其次,我可以将这些修改后的文件 A、B、C 的副本保存到 tmp 文件,hg 恢复它们,然后退出,然后将这些 tmp 文件复制回 A、B、C,这是不是一样只是 hg 取消了最后一次提交,但只是做更多的工作?
Yesterday I committed a file and then wanted to hg backout, but Mercurial says cannot backout because I have other modified files in the project…
That's a little bit strange… it is not atomic level on each file? Commit 1 file and then backout 1 file?
Second, I can save a copy of those modified files A, B, C, to tmp files, hg revert them, and then backout, and then copy those tmp files back to A, B, C, and isn't that the same as just hg backout that last commit but just more work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,执行撤销意味着执行合并。合并时,工作副本用作临时空间:合并冲突显示为工作副本中文件的更改,您可以通过编辑工作副本中的文件来解决这些冲突。这就是 Mercurial 坚持要求您在合并或回退之前拥有一个干净的工作副本的原因:当 Mercurial 需要您解决冲突时,确实没有其他好地方可以存储文件。
就我个人而言,我从未遇到过这个问题。我从来没有修改过任何文件——我要么提交它们,要么将它们存储在 MQ 补丁中。如果您不想使用 MQ,那么简单的
就足以处理您的情况。当然,编写扩展的好人已经将其包装成更简单的命令:请参阅 attic 扩展 举个例子。
In general, doing a backout implies doing a merge. When merging, the working copy is used as a scratch space: merge conflicts show up as changes to the files in your working coyp, and you resolve them by editing the files in your working copy. This is the reason why Mercurial insists on you having a clean working copy before you merge or backout: there is really no other good place for Mercurial to store the files when it needs you to resolve conflicts.
Personally, I've never run into this problem. I never have modified files lying around -- I either commit them or I stash them in a MQ patch. If you don't want to use MQ, then a simple
is enough to deal with your case. This has of course been wrapped into easier commands by the nice people who write extensions: see the attic extension for an example.
没有。 Mercurial 不是文件修订工具,而是变更集修订工具。变更集包括受特定变更影响的所有文件,而不是单个文件。
是的,理论上对所有打开的文件进行恢复、取消然后再次编辑这些文件将达到与取消单个文件相同的效果。然而,实际上,存储库的历史记录并不包含每个文件的单独条目,因此您无法仅回滚其中一个文件。
Nope. Mercurial is not a file-revision tool, it's changeset-revision. A changeset includes all the files affected by particular change, not individual files.
Yes, theoretically doing revert on all open files, backout and then editing those files again will achieve the same effect as doing a backout of the individual file. However, in practice the history for the repo does not contain separate entries for each file, so you can't roll back only one of the files.