Has mercurial a simple way to find the tag that contains rev?
Yes, keyword for search is "revsets"
While your (and git-doc) definition is rather dirty (which tag from a possible set), I'll show step-by-step solution for case "first tag including changeset CSID"
Testing ground
Conditions
In order to satisfy most of the requirements of the task, for such a list of tags (part of a complete one), I decided to use a changeset between 2084 and 2089 and want to have 1.0.0b1
as result
hg-git> hg tags
tip 2167:b963d11cc1c8
1.0.0 2137:6f22e3887d82
1.0.0b2.post1 2106:ff6274c7c614
1.0.0b2 2104:d31a72cf70bd
1.0.0b1 2089:311e9a57959e
0.10.4 2084:bc5339fcea1e
...
our range
hg-git> hg log -r 2084:2089 -T compact
2084[0.10.4]:2082 bc5339fcea1e 2022-01-26 18:40 +0100 danchr
NEWS: 0.10.4 release
2085 da261c503c13 2022-01-26 18:40 +0100 danchr
Added tag 0.10.4 for changeset bc5339fcea1e
2086 ec721ee0f93b 2022-01-26 18:40 +0100 danchr
Added signature for changeset bc5339fcea1e
2087:2083,2086 729775377f6b 2022-01-26 18:49 +0100 danchr
merge with branch 0.10.x
2088 08347725306b 2021-12-24 13:23 +0100 danchr
versioning: create branch 1.0.x
2089[1.0.0b1] 311e9a57959e 2021-12-24 13:21 +0100 danchr
NEWS: 1.0b1 release
I'll use 2086 for CSID
Solution
Get all descendants of CSID
hg log -r "descendants(2086)"
or it can be shorter hg log -r 2086:
, but I want revsets from start (output missed due to the obviousness of the result)
Shorten the output, leaving only the tags
hg-git> hg log -r "descendants(2086) and tag()" -T compact
2089[1.0.0b1] 311e9a57959e 2021-12-24 13:21 +0100 danchr
NEWS: 1.0b1 release
2104[1.0.0b2] d31a72cf70bd 2022-03-10 15:58 +0100 danchr
NEWS: 1.0b2 release
2106[1.0.0b2.post1] ff6274c7c614 2022-03-10 16:11 +0100 danchr
Added signature for changeset d31a72cf70bd
2137[1.0.0] 6f22e3887d82 2022-04-01 16:54 +0200 danchr
NEWS: 1.0.0 release!
Shorten the output, leaving only the first tag
hg-git> hg log -r "first(descendants(2086) and tag())" -T compact
2089[1.0.0b1] 311e9a57959e 2021-12-24 13:21 +0100 danchr
NEWS: 1.0b1 release
Shorten the output, leaving only needed data (changeset+tag+date f.e)
hg-git> hg log -r "first(descendants(2086) and tag())" -T "{node|short}:{tags} {date|shortdate}\n"
311e9a57959e:1.0.0b1 2021-12-24
Bonus Game
Shorten the command for easy re-use later:
revset (data of -r
option) moved into [revsetalias]
section (hg help revsets
) of repo-hgrc or global config (hg help revsets
) and one parameter cs
added for using with any CSID
[revsetalias]
ft(cs) = first(descendants(cs) and tag())
template of output (data of -T
option) moved into [templates]
(hg help templating
) section of...
[templates]
tagid = "{node|short}:{tags} {date|shortdate}\n"
and final command turns into something like
hg log -r "ft(ec721ee0f93b)" -T tagid
PS
With TortoiseHG you can easy debug and visualize your revsets, using filter toolbar for defining revsets by hand and|or visual query editor for GUI

