Match a revset pattern against repo.changegroup?

Angel Ezquerra angel.ezquerra at gmail.com
Mon Oct 10 06:52:39 CDT 2011


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. I
don't have a very clear idea of the different types of "repo" objects
in mercurial, though. The repo object I'm working with is the one that
you get when the "pretxnchangegroup" hook is executed:

def reposetup(ui, repo):
    ui.setconfig("hooks", "pretxnchangegroup.ban-changesets",
checkForBannedChangesets)

where "checkForBannedChangesets" is defined as:

def checkForBannedChangesets(ui, repo, **kwargs)

Any idea of what can be going on? I'm sorry if this is obvious!

Thanks,

Angel


More information about the Mercurial-devel mailing list