Mercurial > public > mercurial-scm > hg
diff hgext/remotenames.py @ 43105:649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
.iteritems() -> .items() is the last source transform being performed.
But it is also the most widely used.
This commit adds a pycompat.iteritems symbol and imports it in place
of .iteritems() for usage in hgext/. I chose to stop at just hgext/
because the patch will be large and it is an easy boundary to stop at
since we can disable source transformation on a per-package basis.
There are places where the type does implement items() and we could
call items() directly. However, this would require critical thought
and I thought it would be easier to just blindly change the code. We
know which call sites need to be audited in the future because they
have "pycompat.iteritems."
With this change, we no longer perform source transformation on
hgext!
Differential Revision: https://phab.mercurial-scm.org/D7014
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Oct 2019 19:25:18 -0400 |
parents | 687b865b95ad |
children | 89a2afe31e82 |
line wrap: on
line diff
--- a/hgext/remotenames.py Sun Oct 06 17:59:15 2019 -0400 +++ b/hgext/remotenames.py Sun Oct 06 19:25:18 2019 -0400 @@ -165,7 +165,7 @@ if not self.loaded: self._load() - for k, vtup in self.potentialentries.iteritems(): + for k, vtup in pycompat.iteritems(self.potentialentries): yield (k, [bin(vtup[0])]) items = iteritems @@ -202,7 +202,7 @@ if not self._nodetobmarks: bmarktonodes = self.bmarktonodes() self._nodetobmarks = {} - for name, node in bmarktonodes.iteritems(): + for name, node in pycompat.iteritems(bmarktonodes): self._nodetobmarks.setdefault(node[0], []).append(name) return self._nodetobmarks @@ -213,7 +213,7 @@ if not self._nodetobranch: branchtonodes = self.branchtonodes() self._nodetobranch = {} - for name, nodes in branchtonodes.iteritems(): + for name, nodes in pycompat.iteritems(branchtonodes): for node in nodes: self._nodetobranch.setdefault(node, []).append(name) return self._nodetobranch @@ -223,7 +223,7 @@ marktonodes = self.bmarktonodes() self._hoisttonodes = {} hoist += b'/' - for name, node in marktonodes.iteritems(): + for name, node in pycompat.iteritems(marktonodes): if name.startswith(hoist): name = name[len(hoist) :] self._hoisttonodes[name] = node @@ -234,7 +234,7 @@ marktonodes = self.bmarktonodes() self._nodetohoists = {} hoist += b'/' - for name, node in marktonodes.iteritems(): + for name, node in pycompat.iteritems(marktonodes): if name.startswith(hoist): name = name[len(hoist) :] self._nodetohoists.setdefault(node[0], []).append(name)