comparison hgext/githelp.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 8ff1ecfadcd1
comparison
equal deleted inserted replaced
43104:74802979dd9d 43105:649d3ac37a12
114 114
115 args = list([convert(x) for x in args]) 115 args = list([convert(x) for x in args])
116 opts = dict( 116 opts = dict(
117 [ 117 [
118 (k, convert(v)) if isinstance(v, str) else (k, v) 118 (k, convert(v)) if isinstance(v, str) else (k, v)
119 for k, v in opts.iteritems() 119 for k, v in pycompat.iteritems(opts)
120 ] 120 ]
121 ) 121 )
122 122
123 return args, opts 123 return args, opts
124 124
130 self.opts = {} 130 self.opts = {}
131 131
132 def __bytes__(self): 132 def __bytes__(self):
133 cmd = b"hg " + self.name 133 cmd = b"hg " + self.name
134 if self.opts: 134 if self.opts:
135 for k, values in sorted(self.opts.iteritems()): 135 for k, values in sorted(pycompat.iteritems(self.opts)):
136 for v in values: 136 for v in values:
137 if v: 137 if v:
138 if isinstance(v, int): 138 if isinstance(v, int):
139 fmt = b' %s %d' 139 fmt = b' %s %d'
140 else: 140 else: