当我使用 mercurial 命令 (hg commit --amend
) 时,它总是会打开编辑器窗口。在 git 中,我可以通过 git commit -a --amend -CHEAD
来避免这种情况,是否有与 mercurial 等效的东西?
最佳答案
鉴于您已经并且正在使用 hg commit --amend
,最简单的方法是诱使 Mercurial 使用不执行任何操作的编辑器,使消息文件保持不变并因此可用:
$ hg --config ui.editor=true commit --amend
saved backup bundle to [long path redacted]
也就是说,Mercurial 确实打开了一个“编辑器窗口”(或编辑器命令,无论如何),只是这个——/bin/true
——立即说“一切正常”,无需触摸交互式终端。
注意:如果您在环境中设置了 HGEDITOR
,这实际上会覆盖 ui.editor
:
def geteditor(self):
'''return editor to use'''
if pycompat.sysplatform == 'plan9':
# vi is the MIPS instruction simulator on Plan 9. We
# instead default to E to plumb commit messages to
# avoid confusion.
editor = 'E'
else:
editor = 'vi'
return (encoding.environ.get("HGEDITOR") or
self.config("ui", "editor") or
encoding.environ.get("VISUAL") or
encoding.environ.get("EDITOR", editor))
所以:
HGEDITOR=true hg commit --amend
将更可靠地做同样的事情(并且输入更少),但在文档中没有这样调用,它只说 HGEDITOR
已被弃用。
关于git - 在没有打开编辑器窗口的情况下修改 Mercurial 提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53797841/