How do I customize the 'commit message file' generated by `hg commit`?

后端 未结 6 557
星月不相逢
星月不相逢 2021-01-17 22:14

When I run hg commit, Mercurial generates a file for my commit message that looks like this :

HG: Enter commit message.  Lines beginning with \'         


        
6条回答
  •  臣服心动
    2021-01-17 22:38

    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:

    [ui]
    editor = c:\path\to\hgedit.cmd
    

    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:

    @echo off
    hg status --unknown>>%1
    notepad %1
    

    If you want to append the output of hg as comments you could do this:

    @echo off
    echo HG: -->>%1
    echo HG: Unknown files:>>%1
    for /f "tokens=*" %%a in ('hg st --unknown') do echo HG: %%a>>%1
    notepad %1
    

    (You don't have to use notepad of course.)

提交回复
热议问题