I'm trying to use mercurial to give me the tag that contains a specific commit, just like git describe --contains
, as described in documentation:
--contains Instead of finding the tag that predates the commit, find the tag that comes after the commit, and thus contains it. Automatically implies --tags.
hg log -r <rev> --template '{latesttag}\n'
doesn't fit the bill as it returns the most recent tag reachable from <rev>
.
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 resultour range
I'll use 2086 for CSID
Solution
Get all descendants of CSID
hg log -r "descendants(2086)"
or it can be shorterhg 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
Shorten the output, leaving only the first tag
Shorten the output, leaving only needed data (changeset+tag+date f.e)
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 parametercs
added for using with any CSIDtemplate of output (data of
-T
option) moved into[templates]
(hg help templating
) section of...and final command turns into something like
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