diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2215,7 +2215,7 @@ def commitforceeditor(repo, ctx, subs, f # run editor in the repository root olddir = os.getcwd() os.chdir(repo.root) - text = repo.ui.edit(committext, ctx.user(), ctx.extra()) + text = repo.ui.edit(committext, ctx.user(), ctx.extra(), editform=editform) text = re.sub("(?m)^HG:.*(\n|$)", "", text) os.chdir(olddir) diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -420,6 +420,10 @@ For example, ``changeset.tag.remove`` cu only for :hg:`tag --remove`, but ``changeset.tag`` customizes the commit message for :hg:`tag` regardless of ``--remove`` option. +At the external editor invocation for committing, corresponding +dot-separated list of names without ``changeset.`` prefix +(e.g. ``commit.normal``) is in ``HGEDITFORM`` environment variable. + In this section, items other than ``changeset`` can be referred from others. For example, the configuration to list committed files up below can be referred as ``{listupfiles}``:: diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -728,7 +728,7 @@ class ui(object): if self.debugflag: opts['label'] = opts.get('label', '') + ' ui.debug' self.write(*msg, **opts) - def edit(self, text, user, extra={}): + def edit(self, text, user, extra={}, editform=None): (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt", text=True) try: @@ -743,6 +743,8 @@ class ui(object): if label in extra: environ.update({'HGREVISION': extra[label]}) break + if editform: + environ.update({'HGEDITFORM': editform}) editor = self.geteditor() diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -4,7 +4,12 @@ commit date test $ cd test $ echo foo > foo $ hg add foo - $ HGEDITOR=true hg commit -m "" + $ cat > $TESTTMP/checkeditform.sh < env | grep HGEDITFORM + > true + > EOF + $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m "" + HGEDITFORM=commit.normal abort: empty commit message [255] $ hg commit -d '0 0' -m commit-1