comparison hgext/rebase.py @ 48913: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 2cce2fa5bcf7
comparison
equal deleted inserted replaced
48912:a0674e916fb6 48913:f254fc73d956
241 f.write(b'%d\n' % int(self.collapsef)) 241 f.write(b'%d\n' % int(self.collapsef))
242 f.write(b'%d\n' % int(self.keepf)) 242 f.write(b'%d\n' % int(self.keepf))
243 f.write(b'%d\n' % int(self.keepbranchesf)) 243 f.write(b'%d\n' % int(self.keepbranchesf))
244 f.write(b'%s\n' % (self.activebookmark or b'')) 244 f.write(b'%s\n' % (self.activebookmark or b''))
245 destmap = self.destmap 245 destmap = self.destmap
246 for d, v in pycompat.iteritems(self.state): 246 for d, v in self.state.items():
247 oldrev = repo[d].hex() 247 oldrev = repo[d].hex()
248 if v >= 0: 248 if v >= 0:
249 newrev = repo[v].hex() 249 newrev = repo[v].hex()
250 else: 250 else:
251 newrev = b"%d" % v 251 newrev = b"%d" % v
503 if tr: 503 if tr:
504 # When using single transaction, store state when transaction 504 # When using single transaction, store state when transaction
505 # commits. 505 # commits.
506 self.storestatus(tr) 506 self.storestatus(tr)
507 507
508 cands = [k for k, v in pycompat.iteritems(self.state) if v == revtodo] 508 cands = [k for k, v in self.state.items() if v == revtodo]
509 p = repo.ui.makeprogress( 509 p = repo.ui.makeprogress(
510 _(b"rebasing"), unit=_(b'changesets'), total=len(cands) 510 _(b"rebasing"), unit=_(b'changesets'), total=len(cands)
511 ) 511 )
512 512
513 def progress(ctx): 513 def progress(ctx):
1334 bpbase[bp] = bpbase.get(bp, []) + [b] 1334 bpbase[bp] = bpbase.get(bp, []) + [b]
1335 if None in bpbase: 1335 if None in bpbase:
1336 # emulate the old behavior, showing "nothing to rebase" (a better 1336 # emulate the old behavior, showing "nothing to rebase" (a better
1337 # behavior may be abort with "cannot find branching point" error) 1337 # behavior may be abort with "cannot find branching point" error)
1338 bpbase.clear() 1338 bpbase.clear()
1339 for bp, bs in pycompat.iteritems(bpbase): # calculate roots 1339 for bp, bs in bpbase.items(): # calculate roots
1340 roots += list(repo.revs(b'children(%d) & ancestors(%ld)', bp, bs)) 1340 roots += list(repo.revs(b'children(%d) & ancestors(%ld)', bp, bs))
1341 1341
1342 rebaseset = repo.revs(b'%ld::', roots) 1342 rebaseset = repo.revs(b'%ld::', roots)
1343 1343
1344 if not rebaseset: 1344 if not rebaseset:
2101 if fm: 2101 if fm:
2102 hf = fm.hexfunc 2102 hf = fm.hexfunc
2103 fl = fm.formatlist 2103 fl = fm.formatlist
2104 fd = fm.formatdict 2104 fd = fm.formatdict
2105 changes = {} 2105 changes = {}
2106 for oldns, newn in pycompat.iteritems(replacements): 2106 for oldns, newn in replacements.items():
2107 for oldn in oldns: 2107 for oldn in oldns:
2108 changes[hf(oldn)] = fl([hf(n) for n in newn], name=b'node') 2108 changes[hf(oldn)] = fl([hf(n) for n in newn], name=b'node')
2109 nodechanges = fd(changes, key=b"oldnode", value=b"newnodes") 2109 nodechanges = fd(changes, key=b"oldnode", value=b"newnodes")
2110 fm.data(nodechanges=nodechanges) 2110 fm.data(nodechanges=nodechanges)
2111 if keepf: 2111 if keepf: