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

Marc Strapetz marc.strapetz at syntevo.com
Tue Apr 7 13:55:04 UTC 2015


I'm taking this thread from the main list to the developers list:

I'm looking for a way to enrich a file log (or sub-tree log) by 
branches, tags and bookmarks: every such "tag" should be displayed at 
the "closest" commit of the file log, i.e. at that commit which contains 
the file in identical state (content).

Here is an example of how this should look like for setup.py of the 
Mercurial repository (note that this repository is quite outdated, so 
most recent tags do not show up):

http://i.imgur.com/AYt885I.png

Using a loop of revset queries gives me the information I'm looking for, 
but is too inefficient (pseudo-code):

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

For this approach, e.g. ancestors() as well as file(setup.py) is run for 
every tag (N times), while I'm having in mind a solution which would 
traverse the commit hierarchy only once or twice, possibly increasing 
memory usage by O(N) for the sake of constant running time. (Is that 
reasonable for large repositories, like for the CPython repository?)

Unfortunately my Python and Mercurial knowledge are quite limited and 
hence I'm looking here for someone who is able to write an extension to 
solve this problem on a work-for-hire basis.

-Marc



-------- Forwarded Message --------
Subject: Re: Fwd: Enriching a file log by branches, tags and bookmarks
Date: Tue, 07 Apr 2015 15:27:41 +0200
From: Marc Strapetz <marc.strapetz at syntevo.com>
To: Matt Mackall <mpm at selenic.com>
CC: Dave S <snidely.too at gmail.com>, mercurial <mercurial at selenic.com>

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-devel mailing list