configure external editor a script

Simon King simon at simonking.org.uk
Wed Oct 19 13:39:22 UTC 2016


On Wed, Oct 19, 2016 at 2:14 PM, Uwe Brauer <oub at mat.ucm.es> wrote:
> Hi
>
> Following
> https://stackoverflow.com/questions/4291826/how-do-i-customize-the-commit-message-file-generated-by-hg-commit
> I tried the following
>
> editor = /home/oub/scripts/hg-commit-editor
>
> With
>
> #!/bin/sh
> hg status --unknown | sed -e 's|^|HG: |' >> $1
> /opt/emacs25/bin/emacsclient $1
>
> Still the file for the commit message is opened in /tmp not in the local
> repo directory.
>
> Any comments?

Mercurial uses the python "mkstemp" function to create a temporary
file with the default commit message, then launches the configured
editor on that temporary file:

    https://selenic.com/hg/file/stable/mercurial/ui.py#l994

mkstemp will use the TMPDIR, TEMP or TMP environment variables as the
directory for the temporary file:

    https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp

So if you set one of those environment variables before committing,
you can control the location of the temporary file. You could even do
that in an alias:

    [alias]
    uwecommit = !TMPDIR=$($HG root) $HG commit "$@"

Hope that helps,

Simon



More information about the Mercurial mailing list