[PATCH V2] revset: add "matching" keyword

Angel Ezquerra angel.ezquerra at gmail.com
Mon Apr 9 17:03:25 CDT 2012


On Thu, Apr 5, 2012 at 11:03 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Wed, 2012-04-04 at 00:56 +0200, Angel Ezquerra wrote:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra at gmail.com>
>> # Date 1333282334 -7200
>> # Node ID 3e65ae4b56dbc669c90613be40fb5b0f7cbe30e2
>> # Parent  f350021ee32ed22b8bd7d3211a8899df0e3d6552
>> revset: add "matching" keyword
>>
>> This keyword can be used to find revisions that "match" one or more fields of a
>> given set of revisions.
>>
>> A revision matches another if all the selected fields (description, author,
>> files, date, parents and/or substate) match the corresponding values of those
>> fields on the source revision.
>>
>> By default this keyword looks for revisions that whose metadata match
>> (description, author and date) making it ideal to look for duplicate revisions.
>>
>> matching takes 2 arguments (the second being optional):
>>
>> 1.- rev: a revset represeting a _single_ revision (e.g. tip, ., p1(.), etc)
>> 2.- [field(s) to match]: an optional field or list of fields to match.
>>   By default matching will match the metadata fields (description, author and
>>   date). When matching more than one field, they must be input as a list. When
>>   matching a single field there is no need to surround it in () to make it a
>>   list.
>>
>> Examples:
>>
>> 1.- Look for revisions with the same metadata (author, description and date)
>> as the 11th revision:
>>
>> hg log -r "matching(11)"
>>
>> 2.- Look for revisions with the same description as the 11th revision:
>>
>> hg log -r "matching(11, description)"
>>
>> You do not need to type the whole 'description' word. You could also use
>> 'descript' or 'desc' but not 'd' because 'd' also matches 'date' and 'date'
>> takes prefecedence because fields are matched in alphabetical order.
>>
>> 3.- Look for revisions with the same author as the current revision:
>>
>> hg log -r "matching(., author)"
>>
>> You could use 'user' rather than 'author' to get the same result.
>>
>> 4.- Look for revisions with the same description _AND_ author as the tip of the
>> repository:
>>
>> hg log -r "matching(tip, (author, desc))"
>
> This second arg is a bit weird. Subexpressions are normally revsets, so
> this could confuse things like the optimizer and the alias engine.
> Compare sort, which instead does:
>
> sort(<some expression>, "author desc")

OK, I'll change it to only accept a string and do a split to get a
list of fields instead.

What do you think about specifying the order in which fields are
matched rather than relying on it being done on alphabetical order?

Angel


More information about the Mercurial-devel mailing list