[PATCH 1 of 5 stable] patch: update copying of dict keys and values to work on Python 3

Augie Fackler raf at durin42.com
Mon Jul 24 19:13:09 EDT 2017


On Jul 24, 2017 5:27 PM, "Martin von Zweigbergk" <martinvonz at google.com>
wrote:

On Mon, Jul 24, 2017 at 2:08 PM, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1500921775 14400
> #      Mon Jul 24 14:42:55 2017 -0400
> # Branch stable
> # Node ID a67471f29dbb38e5ac51a9bacf4bb5fff076e1bb
> # Parent  e12c3049af8ee85dfcf0575297fd568dde5cc8d2
> patch: update copying of dict keys and values to work on Python 3
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -2569,7 +2569,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi
>
>      if relroot != '' and (repo.ui.configbool('devel', 'all-warnings')
>                            or repo.ui.configbool('devel',
'check-relroot')):
> -        for f in modified + added + removed + copy.keys() +
copy.values():
> +        for f in modified + added + removed + list(copy) +
list(copy.values()):

For default, would itertools.chain(modified, added, removed, copy,
copy.values()) be better? OTOH, it's only run when developer warnings
are on, so it's just a matter of aesthetics, I guess.


Probably not, since we're making a full copy and the iterator overhead is
probably higher than the raw copies are.

I didn't check though.


>              if f is not None and not f.startswith(relroot):
>                  raise AssertionError(
>                      "file %s doesn't start with relroot %s" % (f,
relroot))
> _______________________________________________
> 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/20170724/169095c5/attachment.html>


More information about the Mercurial-devel mailing list