reading revision info and feeding it into a revset

Simon King simon at simonking.org.uk
Sat Mar 31 09:11:36 UTC 2012


On 31 Mar 2012, at 01:53, Angel Ezquerra <ezquerra at gmail.com> wrote:

> Hi,
> 
> currently when you make a revset and you use a function such as
> author() you must provide it with a string containing the information
> that you want to look for.
> 
> It'd be very cool to be able to get the information from a given
> revision, rather than typing it explicitly. For example you could get
> the author from revision 12045 and and pass it to author(), creating a
> revset such as:
> 
> author(revuser(12045))
> 
> or perhaps:
> 
> author(info(12045, 'user'))
> 
> This could not be limited to getting the author of course. Ideally you
> could get any of the revision metadata (author, description, date,
> etc).
> 
> This would let you do cool things such as finding "similar" revisions:
> 
> keyword(revdescription(12045))
> 
> I don't think this is currently possible. I guess on unix you could do
> some sort of command execution to run the log command with some
> template and pass the result to the revset, but at least on windows
> this is not easy to do. So it would be great if mercurial supported
> this.
> 
> Looking briefly at the revset.py code it seems that in order to do
> this you'd need to do some sort of "early" substitution on the parse
> tree. An alternative would be to modify the getstring method to also
> get an (optional) repo object, and use it to call the "info" function
> if necessary. This would also require modifying every call to the
> getstring function, which does not seem a very clean solution.
> 
> What do you guys think? Perhaps this is already possible and I just missed it?
> 

A simpler function to implement might be:

similar(rev, attribute)

...which returns revisions that share the same value for "attribute" as "rev"

Ie. similar(12045, "author") would return the revisions that had the same author as rev 12045. This shouldn't need any changes to the way revsets are parsed.

Simon


More information about the Mercurial-devel mailing list