Fwd: Enriching a file log by branches, tags and bookmarks

Marc Strapetz marc.strapetz at syntevo.com
Tue Apr 7 13:27:41 UTC 2015


On 03.04.2015 17:53, Matt Mackall wrote:
> On Fri, 2015-04-03 at 15:55 +0200, Marc Strapetz wrote:
>> On 02.04.2015 21:08, Matt Mackall wrote:
>>> So if the file log shows revisions 1 and 10, but there's a 1.0 tag at 5,
>>> we want to show the tag on 1 to say "this was in 1.0". Right now {tags}
>>> will only tell you about tags on the current changeset and doesn't know
>>> which set of changesets are going to be displayed.
>>>
>>> So we don't in fact have a good way to do what's wanted here in a
>>> template at present.
>>
>> I'm not necessarily looking for a template, it will also be fine if this
>> could be done within a plugin. I couldn't find any high-level API which
>> I could use to compose something useful here. Do you have any suggestions?
>>
>>> However, I do find this useful:
>>>
>>> [alias]
>>> tagged = log -r 'first($1:: and tagged())'
>>
>> AFAIU this gives me the most recent tag for a specific revision? I don't
>> understand what happens here but could that be generalized to do what
>> I'm looking for?
>
> $ hg log -r 'last(::. and file(COPYING))'
> changeset:   14512:8c8b55733cbd
> user:        Matt Mackall <mpm at selenic.com>
> date:        Thu Jun 02 11:17:02 2011 -0500
> summary:     COPYING: refresh with current address from fsf.org
>
> The last ancestor (::) of my current working copy (.) to touch COPYING was changeset 14512.
>
> $ hg log -r 'first(14512:: and tagged())'
> changeset:   14825:de9eb6b1da4f
> branch:      stable
> tag:         1.9
> user:        Mads Kiilerich <mads at kiilerich.com>
> date:        Fri Jul 01 17:37:09 2011 +0200
> summary:     util: rename the util.localpath that uses url to urllocalpath (issue2875)
>
> The first descendant (:: on the other side) of 14512 that was tagged was 1.9 on Jul 1 2011.
>
> $ hg tagged 14512 -T "{tags}\n"
> 1.9
>
> Put it all together:
>
> $ hg log -r 'first(last(::. and file(COPYING)):: and tagged())' -T "{tags}\n"
> 1.9

Using revsets query, for a single tag this seems to be what I'm looking for:

$ hg log -r "max(ancestors(tagged(2.0)) and file(setup.py))" -T"{rev}\n"
15388

However, I need the iteration over all tags, so something like:

$ hg log -r "for all X in tags(): max(ancestors(tagged(X)) and 
file(setup.py))" -T "{X} {rev}\n"

AFAIU, such kind of loops are not supported by revsets, so I've 
implemented this loop outside of Mercurial, but using the command server 
API. For the Mercurial repository, file setup.py, the time required to 
get the information I'm looking for is roughly 7 seconds. That's 
acceptable. For the CPython repository, file .hgtags, it takes roughly 
50 seconds which is too slow. So looks like revsets won't solve my problem.

-Marc








More information about the Mercurial mailing list