Match a revset pattern against repo.changegroup?
idankk86 at gmail.com
Mon Oct 10 10:40:43 CDT 2011
On Mon, Oct 10, 2011 at 1:52 PM, Angel Ezquerra <angel.ezquerra at gmail.com>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. 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)
> Giving this a try, I got the following error:
> AttributeError: 'mqrepo' object has no attribute 'set'
> Looking at localrepo.py I can see that there is a set() method.
The hg that is running your hook is probably old and doesn't have
the set function yet (AFAIK it's in default and hasn't made it to any
public version yet).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mercurial-devel