如何自定义`hg commit`生成的'commit message file'?

hwi*_*ers 8 mercurial

当我运行时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 <hwiechers@gmail.com>
HG: branch 'default'
HG: added a.txt
Run Code Online (Sandbox Code Playgroud)

有没有办法自定义这个文件?我想包括工作副本是否有任何未知文件.

Mat*_*sdm 6

可以在[committemplate]config 部分指定它(请参阅 参考资料hg help config.committemplate):

 "committemplate"
----------------

"changeset"
    String: configuration in this section is used as the template to
    customize the text shown in the editor when committing.

In addition to pre-defined template keywords, commit log specific one
below can be used for customization:

"extramsg"
    String: Extra message (typically 'Leave message empty to abort
    commit.'). This may be changed by some commands or extensions.

For example, the template configuration below shows as same text as one
shown by default:

  [committemplate]
  changeset = {desc}\n\n
      HG: Enter commit message.  Lines beginning with 'HG:' are removed.
      HG: {extramsg}
      HG: --
      HG: user: {author}\n{ifeq(p2rev, "-1", "",
     "HG: branch merge\n")
     }HG: branch '{branch}'\n{if(activebookmark,
     "HG: bookmark '{activebookmark}'\n")   }{subrepos %
     "HG: subrepo {subrepo}\n"              }{file_adds %
     "HG: added {file}\n"                   }{file_mods %
     "HG: changed {file}\n"                 }{file_dels %
     "HG: removed {file}\n"                 }{if(files, "",
     "HG: no files changed\n")}

"diff()"
    String: show the diff (see 'hg help templates' for detail)
Run Code Online (Sandbox Code Playgroud)


Ry4*_*ase 3

没有官方的方法可以在不修改 Mercurial 本身的情况下做到这一点(不是非常吓人,它是非常干净的 Python),但这里有一种方法可以通过调整 的设置editor部分[ui]来做到这一点~/.hgrc

editor = hg status --unknown >! /tmp/unknown_list ; /usr/bin/vim -c "r /tmp/unknown_list"
Run Code Online (Sandbox Code Playgroud)

也就是说,当然是 Linux 上的 vim,但对于任何操作系统上的任何像样的编辑器都可以做同样的事情。