revset query builder for hglib
Idan Kamara
idankk86 at gmail.com
Fri Jul 22 13:15:22 CDT 2011
I'd like to implement some kind of revset query builder for hglib, here's
what I had in mind:
>>> import revset as rs
>>> rs.branch('default')
<revset: "branch('default')">
>>> rs.branch('default') & rs.range('1.5') & ~rs.merge()
<revset: "branch('default') and '1.5':: and not merge()">
>>> rs.head() & ~rs.closed()
<revset: "head() and not closed()">
>>> rs.sort(rs.date('May 2008'), 'user')
<revset: "sort(date('May 2008'), user)">
>>> (rs.keyword('bug') | rs.keyword('issue')) & ~rs.ancestors(rs.tagged())
<revset: "(keyword('bug') or keyword('issue')) and not ancestors(tagged())">
It will handle quoting, and generally be less prone to typos.
It might not be as concise as raw strings, but I think it's nice.
Real usage within hglib might look like this:
repo = hglib.connect(...)
repo.log(rs.branch('default') & rs.tagged())
vs
repo.log("branch(default) and tagged()")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110722/95464b31/attachment.html>
More information about the Mercurial-devel
mailing list