reading revision info and feeding it into a revset

Angel Ezquerra angel.ezquerra at gmail.com
Sun Apr 1 01:28:23 UTC 2012


On Mar 31, 2012 11:11 AM, "Simon King" <simon at simonking.org.uk> wrote:
>
> 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

That's actually a great idea. I got a patch implementing your suggestion
and it works great. I just need to polish it a little bit. I'll send it
when its done.

Angel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120401/03e5d05f/attachment.html>


More information about the Mercurial-devel mailing list