Mercurial > hg
comparison hgext/convert/hg.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 | eef9a2d67051 |
children | 9d2b2df2c2ba |
comparison
equal
deleted
inserted
replaced
43104:74802979dd9d | 43105:649d3ac37a12 |
---|---|
32 hg, | 32 hg, |
33 lock as lockmod, | 33 lock as lockmod, |
34 merge as mergemod, | 34 merge as mergemod, |
35 node as nodemod, | 35 node as nodemod, |
36 phases, | 36 phases, |
37 pycompat, | |
37 scmutil, | 38 scmutil, |
38 util, | 39 util, |
39 ) | 40 ) |
40 from mercurial.utils import dateutil | 41 from mercurial.utils import dateutil |
41 | 42 |
131 except Exception: | 132 except Exception: |
132 missings.setdefault(b[1], []).append(b[0]) | 133 missings.setdefault(b[1], []).append(b[0]) |
133 | 134 |
134 if missings: | 135 if missings: |
135 self.after() | 136 self.after() |
136 for pbranch, heads in sorted(missings.iteritems()): | 137 for pbranch, heads in sorted(pycompat.iteritems(missings)): |
137 pbranchpath = os.path.join(self.path, pbranch) | 138 pbranchpath = os.path.join(self.path, pbranch) |
138 prepo = hg.peer(self.ui, {}, pbranchpath) | 139 prepo = hg.peer(self.ui, {}, pbranchpath) |
139 self.ui.note( | 140 self.ui.note( |
140 _(b'pulling from %s into %s\n') % (pbranch, branch) | 141 _(b'pulling from %s into %s\n') % (pbranch, branch) |
141 ) | 142 ) |
225 force=True, | 226 force=True, |
226 acceptremote=False, | 227 acceptremote=False, |
227 followcopies=False, | 228 followcopies=False, |
228 ) | 229 ) |
229 | 230 |
230 for file, (action, info, msg) in actions.iteritems(): | 231 for file, (action, info, msg) in pycompat.iteritems(actions): |
231 if source.targetfilebelongstosource(file): | 232 if source.targetfilebelongstosource(file): |
232 # If the file belongs to the source repo, ignore the p2 | 233 # If the file belongs to the source repo, ignore the p2 |
233 # since it will be covered by the existing fileset. | 234 # since it will be covered by the existing fileset. |
234 continue | 235 continue |
235 | 236 |
415 def puttags(self, tags): | 416 def puttags(self, tags): |
416 tagparent = self.repo.branchtip(self.tagsbranch, ignoremissing=True) | 417 tagparent = self.repo.branchtip(self.tagsbranch, ignoremissing=True) |
417 tagparent = tagparent or nodemod.nullid | 418 tagparent = tagparent or nodemod.nullid |
418 | 419 |
419 oldlines = set() | 420 oldlines = set() |
420 for branch, heads in self.repo.branchmap().iteritems(): | 421 for branch, heads in pycompat.iteritems(self.repo.branchmap()): |
421 for h in heads: | 422 for h in heads: |
422 if b'.hgtags' in self.repo[h]: | 423 if b'.hgtags' in self.repo[h]: |
423 oldlines.update( | 424 oldlines.update( |
424 set(self.repo[h][b'.hgtags'].data().splitlines(True)) | 425 set(self.repo[h][b'.hgtags'].data().splitlines(True)) |
425 ) | 426 ) |
587 def _changedfiles(self, ctx1, ctx2): | 588 def _changedfiles(self, ctx1, ctx2): |
588 ma, r = [], [] | 589 ma, r = [], [] |
589 maappend = ma.append | 590 maappend = ma.append |
590 rappend = r.append | 591 rappend = r.append |
591 d = ctx1.manifest().diff(ctx2.manifest()) | 592 d = ctx1.manifest().diff(ctx2.manifest()) |
592 for f, ((node1, flag1), (node2, flag2)) in d.iteritems(): | 593 for f, ((node1, flag1), (node2, flag2)) in pycompat.iteritems(d): |
593 if node2 is None: | 594 if node2 is None: |
594 rappend(f) | 595 rappend(f) |
595 else: | 596 else: |
596 maappend(f) | 597 maappend(f) |
597 return ma, r | 598 return ma, r |
613 # revlogs are detected early | 614 # revlogs are detected early |
614 copies = self._getcopies(ctx, parents, copyfiles) | 615 copies = self._getcopies(ctx, parents, copyfiles) |
615 cleanp2 = set() | 616 cleanp2 = set() |
616 if len(parents) == 2: | 617 if len(parents) == 2: |
617 d = parents[1].manifest().diff(ctx.manifest(), clean=True) | 618 d = parents[1].manifest().diff(ctx.manifest(), clean=True) |
618 for f, value in d.iteritems(): | 619 for f, value in pycompat.iteritems(d): |
619 if value is None: | 620 if value is None: |
620 cleanp2.add(f) | 621 cleanp2.add(f) |
621 changes = [(f, rev) for f in files if f not in self.ignored] | 622 changes = [(f, rev) for f in files if f not in self.ignored] |
622 changes.sort() | 623 changes.sort() |
623 return changes, copies, cleanp2 | 624 return changes, copies, cleanp2 |