Mercurial > hg
changeset 32550:b98199a5c3e1
cleanup: rename all iteritems methods to items and add iteritems alias
Due to a quirk of our module importer setup on Python 3, all calls and
definitions of methods named iteritems() get rewritten at import
time. Unfortunately, this means there's not a good portable way to
access these methods from non-module-loader'ed code like our unit
tests. This change fixes that, which also unblocks test-manifest.py
from passing under Python 3.
We don't presently define any itervalues methods, or we'd need to give
those similar treatment.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 29 May 2017 00:00:02 -0400 |
parents | 633c635a790a |
children | 0ff336a42c39 |
files | mercurial/dirstate.py mercurial/manifest.py mercurial/namespaces.py |
diffstat | 3 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Sun May 28 15:51:07 2017 -0400 +++ b/mercurial/dirstate.py Mon May 29 00:00:02 2017 -0400 @@ -343,9 +343,11 @@ for x in sorted(self._map): yield x - def iteritems(self): + def items(self): return self._map.iteritems() + iteritems = items + def parents(self): return [self._validate(p) for p in self._pl]
--- a/mercurial/manifest.py Sun May 28 15:51:07 2017 -0400 +++ b/mercurial/manifest.py Mon May 29 00:00:02 2017 -0400 @@ -579,9 +579,11 @@ c._lm = self._lm.copy() return c - def iteritems(self): + def items(self): return (x[:2] for x in self._lm.iterentries()) + iteritems = items + def iterentries(self): return self._lm.iterentries() @@ -788,7 +790,7 @@ for x in n.iterentries(): yield x - def iteritems(self): + def items(self): self._load() for p, n in sorted(itertools.chain(self._dirs.items(), self._files.items())): @@ -798,6 +800,8 @@ for f, sn in n.iteritems(): yield f, sn + iteritems = items + def iterkeys(self): self._load() for p in sorted(itertools.chain(self._dirs, self._files)):
--- a/mercurial/namespaces.py Sun May 28 15:51:07 2017 -0400 +++ b/mercurial/namespaces.py Mon May 29 00:00:02 2017 -0400 @@ -66,9 +66,11 @@ def __iter__(self): return self._names.__iter__() - def iteritems(self): + def items(self): return self._names.iteritems() + iteritems = items + def addnamespace(self, namespace, order=None): """register a namespace