Match a revset pattern against repo.changegroup?

Matt Mackall mpm at selenic.com
Sun Oct 9 16:24:46 CDT 2011


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. 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)



-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list