[PATCH 08 of 11] py3: pass ctx.rev() instead of ctx in range()

Gregory Szorc gregory.szorc at gmail.com
Fri Feb 23 21:54:53 EST 2018


On Fri, Feb 23, 2018 at 10:15 AM, Pulkit Goyal <7895pulkit at gmail.com> wrote:

> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1519389273 -19800
> #      Fri Feb 23 18:04:33 2018 +0530
> # Node ID a2b469c5995b4c2602f1bb1c3959d67ee9c08141
> # Parent  457aea9470d03f8e69c873b9aec845256abf9023
> py3: pass ctx.rev() instead of ctx in range()
>
> diff --git a/hgext/acl.py b/hgext/acl.py
> --- a/hgext/acl.py
> +++ b/hgext/acl.py
> @@ -356,7 +356,7 @@ def hook(ui, repo, hooktype, node=None,
>      allow = buildmatch(ui, repo, user, 'acl.allow')
>      deny = buildmatch(ui, repo, user, 'acl.deny')
>
> -    for rev in xrange(repo[node], len(repo)):
> +    for rev in xrange(repo[node].rev(), len(repo)):
>

If someone could enlighten me as to why this works in Python 2 but not
Python 3, I would appreciate it. The new code is obviously correct. I'm
just curious what Python 3 changed about the semantics of range(). I guess
it no longer calls __int__???

Speaking of __int__, it is only defined in one place in the repo: on
context.basectx. I think we should consider removing it: it is too much
coercion magic for my liking.


>          ctx = repo[rev]
>          branch = ctx.branch()
>          if denybranches and denybranches(branch):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180223/d60a48b2/attachment.html>


More information about the Mercurial-devel mailing list