Mercurial: How can I change default tag message template?

Viewed 16

I would like to use some prefix labels in commit messages to quickly identify the kind of commit when viewing the revision log, and for ability to quickly filter down the log.

Some of the prefixes I intend to use are (TAG:, MERGE:, TEST:, STABLE:, TRUE-UP:, FIX():, FEATURE():, & possibly others).

Additionally, for tags I would like to change the default message to be a little more descriptive, like so:

TAG: Added tag v3.4 for e90d0caa766 created on 2022-09-22 01:05:00
Applied fix for foobar.

For tagging, Mercurial seems to not open the editor so I can examine the tag message, so my attempts to debug this have been tedious.

I've tried adding the following to my repo hgrc config file:

[committemplate]
changeset.tag = "TAG: Added tag {tag} for {node|short} created on {date|isodate}\n{desc}"

I've also played around with the [hooks] section and pretag hook.

Additionally, I've tried on the command line with various formatting adjustments:

hg tag -r . -m 'TAG: Added tag {tag} for {node|short} created on {date|isodate}\n{desc}' test4

For the command line attempt above none of this populates the template fields in the message, and for the other attempts in the hgrc config file, this has not altered the commit message not once or even errored.

What am I missing here?

1 Answers
  1. [committemplate] work, if it was added to hgrc (tried at repo-level, not globally), but somehow not in expected form (see below)
  2. Just note: if you'll use "Added tag" wording, you, maybe want to limit area of modified message to only adding tags (hg tag can remove tags also, BTW) with changeset.tag.add

My test-case

  • Hg 6.2.2
  • No redefined committemplate in global config
  • Dumb oneliner for changeset.tag and later for changeset.tag.add
  • Tagging pure in CLI (due to total fails in THG)

Some logs

Plain hg tag -r 0 0.1 + hg tag --remove 0.1 used with changeset.tag redefined (default messages used by hg)

changeset:   2:006c40256d9b
user:        lazybadger
date:        Thu Sep 22 17:05:15 2022 +0500
summary:     Removed tag 0.1

changeset:   1:1927f74a0ec0
user:        lazybadger
date:        Thu Sep 22 17:02:46 2022 +0500
summary:     Added tag 0.1 for changeset 8385f66bee57

Tagging with -e additional option (BEWARE: tag inserted in editor by hand, {tag} nor {tags} are not expanded in changeset.tag.* text)

Editor window

changeset:   7:5aee36e13e4d
tag:         lazybadger
date:        Thu Sep 22 17:13:43 2022 +0500
summary:     TAGGING: Tag 0.3 added
...
changeset:   3:9a4b0a117fb1
user:        lazybadger
date:        Thu Sep 22 17:06:23 2022 +0500
summary:     TAG: Tag 0.1 touched
Related