Match a revset pattern against repo.changegroup?

Angel Ezquerra angel.ezquerra at gmail.com
Sun Oct 9 16:55:38 CDT 2011


On Sun, Oct 9, 2011 at 11:41 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Sun, 2011-10-09 at 23:31 +0200, Angel Ezquerra wrote:
>> On Sun, Oct 9, 2011 at 11:24 PM, Matt Mackall <mpm at selenic.com> wrote:
>> > On Sun, 2011-10-09 at 23:14 +0200, Angel Ezquerra wrote:
>> >> On Sun, Oct 9, 2011 at 10:51 PM, Matt Mackall <mpm at selenic.com> wrote:
>> >> > On Sun, 2011-10-09 at 22:13 +0200, Angel Ezquerra wrote:
>> >> >> Hi,
>> >> >>
>> >> >> is there an easy way to match a revset pattern against the received
>> >> >> changegroup on the pretxnchangegroup hook?
>> >> >
>> >> > Check out repo.set(). This is slightly tricky because it doesn't (yet)
>> >> > have a way to include a sub-expression:
>> >> >
>> >> > for ctx in repo.set("%%n:: and (%s)" % revsetexpr, firstincomingnode):
>> >> >    print "bad", ctx.rev()
>> >>
>> >> Thank you!
>> >>
>> >> I was a bit confused by the %%n, until I read the docstring of the
>> >> revset.formatspec function. For those who don't know, %n is equivalent
>> >> to "hex(arg)".
>> >>
>> >> BTW, is there a better way to get the list of revisions that are being
>> >> pushed during the pretxnchangegroup hook?
>> >
>> > It's a simple as taking the given node and finding all revisions
>> > numerically after it. Due to the append-only rule, that's where all the
>> > new changesets must be.
>>
>> OK, that makes sense, thanks.
>>
>>
>> > And that's just:
>> >
>> > repo.set('%n:', node)
>> >
>> > (note the one ':', my earlier set above is wrong)
>> >
>> > You don't really need contexts and a revset for this, of course:
>> >
>> > xrange(repo[node].rev(), repo['tip'] + 1)
>> >
>>
>> Is one method faster than the other? That is, is there a significant
>> cost when using revision sets in this context?
>
> The xrange method is slightly faster. But if it takes you a few minutes
> to optimize something (or talk about optimizing something) by a few
> microseconds and that code doesn't get run many many millions of times,
> it's a false optimization. This code gets run... once per push.

Sure, I agree. I was just curious :-)

Angel


More information about the Mercurial-devel mailing list