[PATCH 3 of 8 V2] revset: add origin() predicate
Matt Harbison
matt_harbison at yahoo.com
Wed Jun 20 21:44:30 CDT 2012
Matt Mackall wrote:
> On Fri, 2012-06-08 at 00:58 -0400, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison<matt_harbison at yahoo.com>
>> # Date 1337140860 14400
>> # Node ID 9eb8327a534e2f16d66b036771ebaceac93d4b2a
>> # Parent 356bb037ddc0c9ee510cb46e379bc715bce9e139
>> revset: add origin() predicate
>> +def origin(repo, subset, x):
>> + """``origin([set])``
>> + Changesets that were grafted, transplanted or rebased from the given
>> + revisions, or the parent of the working directory.
>> + """
>> + if x:
>> + s = getset(repo, subset, x)
>> + else:
>> + s = tuple(p.rev() for p in repo[None].parents())
>> +
>> + return [r for r in xrange(0, len(repo)) if _getrevsource(repo, r) in s]
>
> Looks like you haven't quite grokked the purpose of subset. It exists to
> narrow the scope of inquiry. So if I do:
>
> hg log -r 'head() and origin(x)'
>
> I need only check the origin of branch heads rather than every revision
> in the repository.
>
So I think what you are saying is the last line should along the lines of:
return [r for r in subset if _getrevsource(repo, r) in s]
because 'subset' has been restricted by the previous predicate(s) along
with the immediately preceding [and|or], and 's' reflects the evaluation
of the parameter to the predicate? I stumbled into that before, but
you're right, it didn't fully click.
Any thoughts on 4 - 6? I really think the transitive forms are the way
to go because it hides the differences between graft and transplant.
(Though I really haven't thought those through yet with this new
understanding. Maybe it isn't possible.)
More information about the Mercurial-devel
mailing list