如何自定义“提交消息文件”由“hg commit”生成?
当我运行 hg commit
时,Mercurial 会为我的提交消息生成一个文件,如下所示:
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Henri Wiechers <[email protected]>
HG: branch 'default'
HG: added a.txt
有没有办法自定义此文件?我想包括工作副本是否有 任何未知文件。
When I run hg commit
, Mercurial generates a file for my commit message that looks like this :
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Henri Wiechers <[email protected]>
HG: branch 'default'
HG: added a.txt
Is there a way to customize this file? I'd like to include if the working copy has
any unknown files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
有很多方法可以做到这一点。有些甚至在官方 wiki 上列出。这扩展了@Ry4an 的答案。您可以将其添加到您的
~/.hgrc
There are many ways to do this. Some are even listed on the official wiki. This expands on @Ry4an answer. You can add this to your
~/.hgrc
可以在
[committemplate]
配置部分中指定它(请参阅hg help config.committemplate
):It's possible to specify this in the
[committemplate]
config section (seehg help config.committemplate
):没有官方的方法可以在不修改 Mercurial 本身的情况下做到这一点(不是非常吓人,它是非常干净的 Python),但这里有一种方法可以通过调整
editor
设置[ui] 来做到这一点
部分:~/.hgrc
的也就是说,当然是 Linux 上的 vim,但对于任何操作系统上的任何像样的编辑器都可以做同样的事情。
There's no official way to do it w/o modifying mercurial itself (not terribly intimidating, it's very clean Python), but here's a way to do it by tweaking the
editor
setting the[ui]
section of your~/.hgrc
:That is, of course vim on Linux specific, but the same could be done for any decent editor on any OS.
我想在windows下做这个。在 ini/.hgrc 文件中自定义编辑器设置的想法使我想到用命令文件替换编辑器命令。
例如,如果您在 Mercurial.ini 中进行设置:
那么 hg 将调用命令文件并在命令行上传递临时文件的名称。然后可以使用 %1 参数在命令文件中访问临时文件名。
hgedit.cmd 可能类似于:
如果您想将 hg 的输出附加为注释,您可以这样做:(
当然,您不必使用记事本。)
I wanted to do this under windows. The idea of customising the editor setting in the ini/.hgrc file made me think of replacing the editor command with a command file.
e.g. if you set this in mercurial.ini:
then hg will call the command file and pass the name of the temp file on the command line. The temp file name can then be accessed in the command file using the %1 parameter.
hgedit.cmd could be something like:
If you want to append the output of hg as comments you could do this:
(You don't have to use notepad of course.)
Jim Eggleston 答案的 Mac/Linux 变体...我制作了一个名为 hg-commit-editor: 的脚本,
然后将其设置为 hgrc 中的提交编辑器:
A Mac/Linux variant of Jim Eggleston's answer... I made a script called hg-commit-editor:
and then set it as my commit editor in my hgrc:
使用
hg commit -m“我的消息在这里”
。您还可以在Mercurial.ini
或~/.hgrc
文件中设置编辑器。添加以下内容:Use
hg commit -m "My message here"
. You can also set up an editor in yourMercurial.ini
or~/.hgrc
file. Add the following: