Mercurial > public > mercurial-scm > hg-stable
diff mercurial/merge.py @ 49004:f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
pycompat.iteritems() just calls .items().
This commit applies a regular expression search and replace to convert
simple instances of pycompat.iteritems() with .items(). There are still
a handful of calls to pycompat.iteritems() remaining. But these all have
more complicated expressions that I wasn't comfortable performing an
automated replace on. In addition, some simple replacements were withheld
because they broke pytype. These will be handled by their own changesets.
Differential Revision: https://phab.mercurial-scm.org/D12318
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 03 Mar 2022 18:28:30 -0800 |
parents | 6000f5b25c9b |
children | c17aee610bab |
line wrap: on
line diff
--- a/mercurial/merge.py Thu Mar 03 17:39:20 2022 -0800 +++ b/mercurial/merge.py Thu Mar 03 18:28:30 2022 -0800 @@ -643,10 +643,10 @@ def filemap(self, sort=False): if sorted: - for key, val in sorted(pycompat.iteritems(self._filemapping)): + for key, val in sorted(self._filemapping.items()): yield key, val else: - for key, val in pycompat.iteritems(self._filemapping): + for key, val in self._filemapping.items(): yield key, val def addcommitinfo(self, filename, key, value): @@ -671,15 +671,15 @@ """returns a dictionary of actions to be perfomed with action as key and a list of files and related arguments as values""" res = collections.defaultdict(list) - for a, d in pycompat.iteritems(self._actionmapping): - for f, (args, msg) in pycompat.iteritems(d): + for a, d in self._actionmapping.items(): + for f, (args, msg) in d.items(): res[a].append((f, args, msg)) return res def setactions(self, actions): self._filemapping = actions self._actionmapping = collections.defaultdict(dict) - for f, (act, data, msg) in pycompat.iteritems(self._filemapping): + for f, (act, data, msg) in self._filemapping.items(): self._actionmapping[act][f] = data, msg def hasconflicts(self): @@ -786,7 +786,7 @@ relevantfiles = set(ma.diff(m2).keys()) # For copied and moved files, we need to add the source file too. - for copykey, copyvalue in pycompat.iteritems(branch_copies1.copy): + for copykey, copyvalue in branch_copies1.copy.items(): if copyvalue in relevantfiles: relevantfiles.add(copykey) for movedirkey in branch_copies1.movewithdir: @@ -796,7 +796,7 @@ diff = m1.diff(m2, match=matcher) - for f, ((n1, fl1), (n2, fl2)) in pycompat.iteritems(diff): + for f, ((n1, fl1), (n2, fl2)) in diff.items(): if n1 and n2: # file exists on both local and remote side if f not in ma: # TODO: what if they're renamed from different sources? @@ -1511,7 +1511,7 @@ ms = wctx.mergestate(clean=True) ms.start(wctx.p1().node(), mctx.node(), labels) - for f, op in pycompat.iteritems(mresult.commitinfo): + for f, op in mresult.commitinfo.items(): # the other side of filenode was choosen while merging, store this in # mergestate so that it can be reused on commit ms.addcommitinfo(f, op) @@ -2072,7 +2072,7 @@ _checkcollision(repo, wc.manifest(), mresult) # divergent renames - for f, fl in sorted(pycompat.iteritems(mresult.diverge)): + for f, fl in sorted(mresult.diverge.items()): repo.ui.warn( _( b"note: possible conflict - %s was renamed " @@ -2084,7 +2084,7 @@ repo.ui.warn(b" %s\n" % nf) # rename and delete - for f, fl in sorted(pycompat.iteritems(mresult.renamedelete)): + for f, fl in sorted(mresult.renamedelete.items()): repo.ui.warn( _( b"note: possible conflict - %s was deleted " @@ -2124,7 +2124,7 @@ if updatedirstate: if extraactions: - for k, acts in pycompat.iteritems(extraactions): + for k, acts in extraactions.items(): for a in acts: mresult.addfile(a[0], k, *a[1:]) if k == mergestatemod.ACTION_GET and wantfiledata: @@ -2195,10 +2195,10 @@ getfiledata = None else: now_sec = now[0] - for f, m in pycompat.iteritems(getfiledata): + for f, m in getfiledata.items(): if m is not None and m[2][0] >= now_sec: ambiguous_mtime[f] = (m[0], m[1], None) - for f, m in pycompat.iteritems(ambiguous_mtime): + for f, m in ambiguous_mtime.items(): getfiledata[f] = m repo.setparents(fp1, fp2)