Search code examples
mercurial

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


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.


Solution

  • 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:

    editor = hg status --unknown >! /tmp/unknown_list ; /usr/bin/vim -c "r /tmp/unknown_list"
    

    That is, of course vim on Linux specific, but the same could be done for any decent editor on any OS.