Mercurial:如何修改最后一次提交? - Mercurial: how to amend the last commit?

10/14 04:49
阅读数 0

问题:

I'm looking for a counter-part of git commit --amend in Mercurial, ie a way to modify the commit which my working copy is linked to.我正在寻找 Mercurial 中git commit --amend的对应部分,即一种修改我的工作副本链接到的提交的方法。 I'm only interested in the last commit, not an arbitrary earlier commit.我只对最后一次提交感兴趣,而不是任意较早的提交。

The requirements for this amend-procedure are:本修正程序的要求是:

  • if possible, it should not require any extensions.如果可能,它不应该需要任何扩展。 It must not require non-default extensions , ie extensions which do not come with an official Mercurial installation.不能要求非默认扩展,即不附带官方 Mercurial 安装的扩展。

  • if the commit to amend is one head of my current branch, no new head should be created.如果要修改的提交是我当前分支的一个负责人,则不应创建新的负责人 If the commit is not head, a new head may be created.如果提交不是头部,则可能会创建一个新的头部。

  • the procedure should be safe in a way that if for whatever reasons the amending fails, I want to have the same working copy and repository state restored as before the amending.该过程应该是安全的,如果由于任何原因修改失败,我希望恢复与修改前相同的工作副本和存储库状态。 With other words, if the amending itself can fail, there should be a fail-safe procedure to restore the working copy and repository state.换句话说,如果修改本身可能失败,那么应该有一个故障安全程序来恢复工作副本和存储库状态。 I'm referring to "failures" which lie in the nature of the amend-procedure (like eg conflicts), not to file-system-related problems (like access restrictions, not being able to lock a file for writing, ...)我指的是修改程序性质中的“失败”(例如冲突),而不是与文件系统相关的问题(例如访问限制,无法锁定文件以进行写入,...... )

Update (1):更新(1):

  • the procedure must be automatable , so it can be performed by a GUI client without any user interaction required.该过程必须是可自动化的,因此它可以由 GUI 客户端执行,无需任何用户交互。

Update (2):更新(2):

  • files in the working directory must not be touched (there may be file system locks on certain modified files).不得触及工作目录中的文件(某些修改过的文件可能存在文件系统锁定)。 This especially means, that a possible approach may at no point require a clean working directory.这尤其意味着,可能的方法在任何时候都不需要干净的工作目录。

解决方案:

参考一: https://en.stackoom.com/question/YKja
参考二: https://stackoom.com/question/YKja
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部