Mercurial > hg
diff hgext/rebase.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 | 74802979dd9d |
children | 8ff1ecfadcd1 |
line wrap: on
line diff
--- a/hgext/rebase.py Sun Oct 06 17:59:15 2019 -0400 +++ b/hgext/rebase.py Sun Oct 06 19:25:18 2019 -0400 @@ -151,7 +151,7 @@ ) repo = ctx.repo() names = [] - for nsname, ns in repo.names.iteritems(): + for nsname, ns in pycompat.iteritems(repo.names): if nsname == b'branches': continue names.extend(ns.names(repo, ctx.node())) @@ -239,7 +239,7 @@ f.write(b'%d\n' % int(self.keepbranchesf)) f.write(b'%s\n' % (self.activebookmark or b'')) destmap = self.destmap - for d, v in self.state.iteritems(): + for d, v in pycompat.iteritems(self.state): oldrev = repo[d].hex() if v >= 0: newrev = repo[v].hex() @@ -489,7 +489,7 @@ # commits. self.storestatus(tr) - cands = [k for k, v in self.state.iteritems() if v == revtodo] + cands = [k for k, v in pycompat.iteritems(self.state) if v == revtodo] p = repo.ui.makeprogress( _(b"rebasing"), unit=_(b'changesets'), total=len(cands) ) @@ -1326,7 +1326,7 @@ # emulate the old behavior, showing "nothing to rebase" (a better # behavior may be abort with "cannot find branching point" error) bpbase.clear() - for bp, bs in bpbase.iteritems(): # calculate roots + for bp, bs in pycompat.iteritems(bpbase): # calculate roots roots += list(repo.revs(b'children(%d) & ancestors(%ld)', bp, bs)) rebaseset = repo.revs(b'%ld::', roots) @@ -1970,7 +1970,7 @@ # We should be standing on the first as-of-yet unrebased commit. firstunrebased = min( - [old for old, new in state.iteritems() if new == nullrev] + [old for old, new in pycompat.iteritems(state) if new == nullrev] ) if firstunrebased in parents: return True @@ -2121,7 +2121,7 @@ fl = fm.formatlist fd = fm.formatdict changes = {} - for oldns, newn in replacements.iteritems(): + for oldns, newn in pycompat.iteritems(replacements): for oldn in oldns: changes[hf(oldn)] = fl([hf(n) for n in newn], name=b'node') nodechanges = fd(changes, key=b"oldnode", value=b"newnodes")