revset query builder for hglib

Idan Kamara idankk86 at gmail.com
Mon Jul 25 11:57:09 CDT 2011


On Mon, Jul 25, 2011 at 6:24 PM, Kevin Bullock <
kbullock+mercurial at ringworld.org> wrote:
> On Jul 23, 2011, at 11:50 AM, Matt Mackall wrote:
>
>> On Sat, 2011-07-23 at 10:54 +0200, Isaac Jurado wrote:
>>> On Fri, Jul 22, 2011 at 8:15 PM, Idan Kamara <idankk86 at gmail.com> wrote:
>>>> I'd like to implement some kind of revset query builder for hglib,
here's
>>>> what I had in mind:
>>>
>>> Isn't that similar to this?
>>>
>>> http://www.selenic.com/pipermail/mercurial-devel/2011-July/033276.html
>>
>> Yes and no.
>>
>> It has the notable advantage that it's parsed by Python's compiler (and
>> probably your editor's syntax highlighter) so mistakes get caught
>> sooner.
>>
>> The downsides are:
>>
>> - it's not as compact
>> - it can't be perfectly one to one with revset grammar
>> - newly-added revset predicates require updating python-hglib
>
> The last one could be solved by letting the query builder operations also
take strings:
>
>>>> rs.branch('default') & 'somenewpredicate()'
>
> since a query builder eventually has to compile to a string to send over
the wire anyway.

Indeed. There's a 'raw' function just for this:
`rs.raw('somenewpredicate()')`:

https://bitbucket.org/idank/python-hglib/changeset/61abd57c8a1f#chg_hglib/revset.py_newline9

I suppose the operators should probably accept strings on the rhs too,
it seems it might be useful like that (as you demonstrated).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110725/3a18a952/attachment.html>


More information about the Mercurial-devel mailing list