Commit 061ac448 authored by Matt Harbison's avatar Matt Harbison

py3: replace dict.iteritems() with .items()

Converted with `2to3 -w -n -f dict .`, and then remove a bunch of list()
wrapping.  The only place it seemed necessary was in repoview.py, as the
collection is traversed more than once.
parent 34cc0899fdbf
......@@ -223,7 +223,7 @@ class build_config(Command):
# Distributions will need to supply their own
f = open(cfgfile, "w")
try:
for k, v in sorted(data.iteritems()):
for k, v in sorted(data.items()):
f.write('%s = %r\n' % (k, v))
finally:
f.close()
......@@ -258,7 +258,7 @@ class build_py2app_config(build_config):
"\n"
"if 'THG_OSX_APP' in os.environ:\n"
" nofork = True\n")
for k, v in sorted(data.iteritems()):
for k, v in sorted(data.items()):
f.write(" %s = os.path.join(%s, '%s')\n" % (k, rsrc_dir, v))
f.write(" bin_path = os.path.dirname(sys.executable)\n")
finally:
......
......@@ -33,7 +33,7 @@ def test_user_hue():
0x4: '#d4aaff', 0x5: '#b4aaff', 0x6: '#aabfff', 0x7: '#aadfff',
0x8: '#aafeff', 0x9: '#aaffdf', 0xa: '#aaffbf', 0xb: '#b4ffaa',
0xc: '#d4ffaa', 0xd: '#f4ffaa', 0xe: '#ffe9aa', 0xf: '#ffc9aa'}
for i, c in sorted(samples.iteritems(), key=lambda a: a[0]):
for i, c in sorted(samples.items(), key=lambda a: a[0]):
assert_equals(c, cm.get_color(fakectx(sys.maxint / 16 * i, 0), 0))
def test_user_hue_limit():
......@@ -43,7 +43,7 @@ def test_user_hue_limit():
0x4: '#ffaae9', 0x5: '#d4aaff', 0x6: '#d4aaff', 0x7: '#aabfff',
0x8: '#aabfff', 0x9: '#aaffff', 0xa: '#aaffff', 0xb: '#aaffbf',
0xc: '#aaffbf', 0xd: '#d4ffaa', 0xe: '#d4ffaa', 0xf: '#ffe9aa'}
for i, c in sorted(samples.iteritems(), key=lambda a: a[0]):
for i, c in sorted(samples.items(), key=lambda a: a[0]):
assert_equals(c, cm.get_color(fakectx(sys.maxint / 16 * i, 0), 0))
SECS_PER_DAY = 24 * 60 * 60
......@@ -55,7 +55,7 @@ def test_age_saturation():
samples = {0: '#ffaaaa', 50: '#ffd4d4', 100: '#ffe2e2', 150: '#ffe9e9',
200: '#ffeeee', 250: '#fff0f0', 300: '#fff2f2', 350: '#fff4f4',
400: '#fff5f5', 450: '#fff6f6', 500: '#fff7f7', 550: '#fff7f7'}
for i, c in sorted(samples.iteritems(), key=lambda a: a[0]):
for i, c in sorted(samples.items(), key=lambda a: a[0]):
assert_equals(c, cm.get_color(fakectx(0, 0), float(i * SECS_PER_DAY)))
def test_age_saturation_limit():
......@@ -64,7 +64,7 @@ def test_age_saturation_limit():
samples = {0: '#ffaaaa', 3: '#ffaaaa', 4: '#ffafaf', 7: '#ffafaf',
8: '#ffb4b4', 11: '#ffb4b4', 12: '#ffb9b9', 16: '#ffb9b9',
17: '#ffbfbf', 22: '#ffbfbf', 23: '#ffc4c4', 29: '#ffc4c4'}
for i, c in sorted(samples.iteritems(), key=lambda a: a[0]):
for i, c in sorted(samples.items(), key=lambda a: a[0]):
assert_equals(c, cm.get_color(fakectx(0, 0), float(i * SECS_PER_DAY)))
def test_age_calc():
......@@ -90,7 +90,7 @@ def test_makeannotatepalette_latest_wins():
palette = colormap.makeannotatepalette(filectxs, now=4, maxcolors=4)
palfctxs = set()
for _color, fctxs in palette.iteritems():
for _color, fctxs in palette.items():
palfctxs.update(fctxs)
assert_equals(set(filectxs[1:]), palfctxs)
......@@ -117,7 +117,7 @@ def test_makeannotatepalette_mindate_included():
maxsaturations=255,
mindate=2 * agestep)
palfctxs = set()
for _color, fctxs in palette.iteritems():
for _color, fctxs in palette.items():
palfctxs.update(fctxs)
for fctx in filectxs[2:]:
assert fctx in palfctxs
......@@ -129,7 +129,7 @@ def test_makeannotatepalette_mindate_earlier_than_rev0():
maxcolors=1, maxhues=1,
maxsaturations=255, mindate=0)
palfctxs = set()
for _color, fctxs in palette.iteritems():
for _color, fctxs in palette.items():
palfctxs.update(fctxs)
for fctx in filectxs:
assert fctx in palfctxs
......@@ -49,7 +49,7 @@ def buildlinetable(grapher, predicate):
lt = dict((p, predicate(p, e)) for p, e
in sorted(node.bottomlines, key=lambda pe: pe[1].importance))
# and sort them in (start, end) order
lines = [l for p, l in sorted(lt.iteritems(), key=lambda pl: pl[0])]
lines = [l for p, l in sorted(lt.items(), key=lambda pl: pl[0])]
table[node.rev] = lines
return table
......
......@@ -18,7 +18,7 @@ def setup():
def newrconfig(vals={}):
c = config.config()
for k, v in isinstance(vals, dict) and vals.iteritems() or vals:
for k, v in isinstance(vals, dict) and vals.items() or vals:
sec, it = k.split('.', 1)
c.set(sec, it, v)
return c
......
......@@ -108,7 +108,7 @@ def readopts(ui):
def commitopts2str(opts, mode='commit'):
optslist = []
for opt, value in opts.iteritems():
for opt, value in opts.items():
if opt in ['user', 'date', 'pushafter', 'autoinc',
'recurseinsubrepos']:
if mode == 'merge' and opt == 'autoinc':
......@@ -985,7 +985,7 @@ class CommitWidget(QWidget, qtlib.TaskWidget):
merge = False
files = self.stwidget.getChecked('MAR?!IS')
# make list of files with partial change selections
for fname, c in self.stwidget.partials.iteritems():
for fname, c in self.stwidget.partials.items():
if c.excludecount > 0 and c.excludecount < len(c.hunks):
partials.append(fname)
self.files = set(files + partials)
......
......@@ -144,7 +144,7 @@ class FilectxActions(QObject):
self._actions = {}
self._customactions = {}
for name, d in self._actiontable.iteritems():
for name, d in self._actiontable.items():
desc, icon, key, tip, fdfilters = d
# QAction must be owned by QWidget; otherwise statusTip for context
# menu cannot be displayed (QTBUG-16114)
......
......@@ -317,7 +317,7 @@ class FileLogDialog(_AbstractFileDialog):
else:
texts = {'visualDiff': _('Diff &Changeset to Parent'),
'visualDiffFile': _('&Diff to Parent')}
for n, t in texts.iteritems():
for n, t in texts.items():
self._fileactions.action(n).setText(t)
@pyqtSlot()
......
......@@ -373,7 +373,7 @@ class HgFileView(QFrame):
def _restrictModes(self, available):
'Disable modes based on content constraints'
available.add(_NullMode)
for m, a in self._modeActionMap.iteritems():
for m, a in self._modeActionMap.items():
a.setEnabled(m in available)
self._fallBackToAvailableMode()
......@@ -1177,7 +1177,7 @@ class _AnnotateViewControl(_AbstractViewControl):
maxsaturations=16,
mindate=mindate,
isdarktheme=self._isdarktheme)
for i, (color, fctxs) in enumerate(palette.iteritems()):
for i, (color, fctxs) in enumerate(palette.items()):
m = _FirstAnnotateLineMarker + i
self._sci.markerDefine(qsci.Background, m)
self._sci.setMarkerBackgroundColor(QColor(color), m)
......
......@@ -157,7 +157,7 @@ class GraftDialog(QDialog):
ui = self.repo.ui
qs = QSettings()
qs.beginGroup('graft')
for n, w in self._optchks.iteritems():
for n, w in self._optchks.items():
if n == 'autoresolve':
w.setChecked(ui.configbool('tortoisehg', n,
qtlib.readBool(qs, n, True)))
......@@ -168,7 +168,7 @@ class GraftDialog(QDialog):
def _writeSettings(self):
qs = QSettings()
qs.beginGroup('graft')
for n, w in self._optchks.iteritems():
for n, w in self._optchks.items():
qs.setValue(n, w.isChecked())
qs.endGroup()
......@@ -200,7 +200,7 @@ class GraftDialog(QDialog):
def graft(self):
self.graftbtn.setEnabled(False)
self.cancelbtn.setVisible(False)
opts = dict((n, w.isChecked()) for n, w in self._optchks.iteritems())
opts = dict((n, w.isChecked()) for n, w in self._optchks.items())
itool = opts.pop('autoresolve') and 'merge' or 'fail'
opts['config'] = 'ui.merge=internal:%s' % itool
if os.path.exists(self._graftstatefile):
......
......@@ -438,7 +438,7 @@ class _FamilyLineRev(object):
if kv[0] not in excluded_descendants)
if self.visible:
for nd, is_p1 in next_descendants.iteritems():
for nd, is_p1 in next_descendants.items():
nd.destinations.append((self.rev, LINE_TYPE_FAMILY, is_p1))
# `next_descendants` are also excluded from next_descendants
......@@ -461,7 +461,7 @@ class _FamilyLineRev(object):
self.next_descendants = self.excluded_descendants = None
def add_next_descendants(self, descendants):
for d, is_p1 in descendants.iteritems():
for d, is_p1 in descendants.items():
if d in self.next_descendants:
self.next_descendants[d] |= is_p1
else:
......
......@@ -804,7 +804,7 @@ class MatchModel(QAbstractTableModel):
else:
snapshots[rev].append(path)
urls = []
for rev, paths in snapshots.iteritems():
for rev, paths in snapshots.items():
if rev is not None:
repo = self._repoagent.rawRepo()
lpaths = pycompat.maplist(hglib.fromunicode, paths)
......
......@@ -289,7 +289,7 @@ class DetectRenameDialog(QDialog):
'destination file:\n%s. Aborting!') % udest)
return
remdests[dest] = src
for dest, src in remdests.iteritems():
for dest, src in remdests.items():
if not os.path.exists(self.repo.wjoin(src)):
wctx.forget([src]) # !->R
wctx.copy(src, dest)
......
......@@ -98,7 +98,7 @@ class QueueManagementActions(QObject):
'deleteQueue': QAction(_('&Delete Queue...'), self),
'purgeQueue': QAction(_('&Purge Queue...'), self),
}
for name, action in self._actions.iteritems():
for name, action in self._actions.items():
action.triggered.connect(getattr(self, '_' + name))
self._updateActions()
......
......@@ -349,7 +349,7 @@ class PostReviewDialog(QDialog):
def cmdargs(opts):
args = []
for k, v in opts.iteritems():
for k, v in opts.items():
if isinstance(v, bool):
if v:
args.append('--%s' % k.replace('_', '-'))
......
......@@ -121,7 +121,7 @@ class PruneWidget(cmdui.AbstractCmdWidget):
def runCommand(self):
opts = {}
opts.update((n, w.isChecked()) for n, w in self._optchks.iteritems())
opts.update((n, w.isChecked()) for n, w in self._optchks.items())
cmdline = hglib.buildcmdargs('prune', rev=self.revset(), **opts)
return self._repoagent.runCommand(cmdline, self)
......
......@@ -840,7 +840,7 @@ class CustomPrompt(QMessageBox):
return self.exec_()
def keyPressEvent(self, event):
for k, btn in self.hotkeys.iteritems():
for k, btn in self.hotkeys.items():
if event.text() == k:
btn.clicked.emit(False)
super(CustomPrompt, self).keyPressEvent(event)
......
......@@ -107,7 +107,7 @@ class QuickOpDialog(QDialog):
defcheck = checktypes[self.command]
opts = {}
for s, val in status.statusTypes.iteritems():
for s, val in status.statusTypes.items():
opts[val.name] = s in filetypes
opts['checkall'] = True # pre-check all matching files
......
......@@ -294,7 +294,7 @@ class HgRepoListModel(QAbstractTableModel):
self._shrinkRowCount() # avoid further exceptions at data()
raise
self._expandRowCount() # old rows may be mapped to inserted rows
for rev, ois in oldindexmap.iteritems():
for rev, ois in oldindexmap.items():
try:
row = self.graph.index(rev)
except ValueError:
......@@ -814,7 +814,7 @@ class HgRepoListModel(QAbstractTableModel):
labels.append((hglib.tounicode(tag), style))
names = set(self.repo.ui.configlist('experimental', 'thg.displaynames'))
for name, ns in self.repo.names.iteritems():
for name, ns in self.repo.names.items():
if name not in names:
continue
# we will use the templatename as the color name since those
......
......@@ -293,14 +293,14 @@ class RepoRegistryView(QDockWidget):
'showNetworkSubrepos': False, 'showShortPaths': True}
s = QSettings()
s.beginGroup('Workbench') # for compatibility with old release
for key, action in self._settingactions.iteritems():
for key, action in self._settingactions.items():
action.setChecked(qtlib.readBool(s, key, defaultmap[key]))
s.endGroup()
def _saveSettings(self):
s = QSettings()
s.beginGroup('Workbench') # for compatibility with old release
for key, action in self._settingactions.iteritems():
for key, action in self._settingactions.items():
s.setValue(key, action.isChecked())
s.endGroup()
s.beginGroup('reporegistry')
......
......@@ -524,7 +524,7 @@ class GraphDelegate(QStyledItemDelegate):
lines = [((start, end), e) for (start, end), e in lines
if start < visibleend or end < visibleend]
# remove hidden lines that can be partly visible due to antialiasing
lines = dict(sorted(lines, key=lineimportance)).items()
lines = list(dict(sorted(lines, key=lineimportance)).items())
# still necessary to sort by importance because lines can partially
# overlap near contact point
lines.sort(key=lineimportance)
......
......@@ -281,7 +281,7 @@ class RepoWidget(QWidget):
def currentTaskTabName(self):
indexmap = dict((idx, name)
for name, idx in self._namedTabs.iteritems())
for name, idx in self._namedTabs.items())
return indexmap.get(self.taskTabsWidget.currentIndex())
@pyqtSlot(str)
......@@ -839,7 +839,7 @@ class RepoWidget(QWidget):
@pyqtSlot(str, dict)
def grep(self, pattern='', opts={}):
"""Open grep task tab"""
opts = dict((str(k), str(v)) for k, v in opts.iteritems())
opts = dict((str(k), str(v)) for k, v in opts.items())
self.taskTabsWidget.setCurrentIndex(self._namedTabs['grep'])
self.grepDemand.setSearch(pattern, **opts)
self.grepDemand.runSearch()
......
......@@ -769,7 +769,7 @@ def help_(ui, name=None, with_version=False, **opts):
def helplist(header, select=None):
h = {}
cmds = {}
for c, e in table.iteritems():
for c, e in table.items():
f = c.split("|", 1)[0]
if select and not select(f):
continue
......
......@@ -224,7 +224,7 @@ class ShellConfigWindow(QDialog):
self.load_shell_configs()
def load_shell_configs(self):
for name, info in vars.iteritems():
for name, info in vars.items():
default, regkey, regtype, evalfunc, wrfunc, cbattr = info
try:
hkey = OpenKey(HKEY_CURRENT_USER, 'Software\\' + regkey)
......@@ -270,7 +270,7 @@ class ShellConfigWindow(QDialog):
hkey = CreateKey(HKEY_CURRENT_USER, "Software\\" + THGKEY)
SetValueEx(hkey, PROMOTEDITEMS, 0, REG_SZ, ','.join(promoted))
for name, info in vars.iteritems():
for name, info in vars.items():
default, regkey, regtype, evalfunc, wrfunc, cbattr = info
if cbattr == None:
continue
......
......@@ -306,7 +306,7 @@ class StatusWidget(QWidget):
# remove files from the partials dictionary if they are not partial
# selections, in order to simplify refresh.
dels = []
for file, oldchanges in self.partials.iteritems():
for file, oldchanges in self.partials.items():
assert file in self.tv.model().checked
if oldchanges.excludecount == 0:
self.tv.model().checked[file] = True
......@@ -598,7 +598,7 @@ class StatusWidget(QWidget):
checked = model.getChecked()
if types is None:
files = []
for f, v in checked.iteritems():
for f, v in checked.items():
if f in self.partials:
changes = self.partials[f]
if changes.excludecount < len(changes.hunks):
......
......@@ -356,7 +356,7 @@ class SyncWidget(QWidget, qtlib.TaskWidget):
self.refreshUrl()
s = QSettings()
for opt, val in self.opts.iteritems():
for opt, val in self.opts.items():
if isinstance(val, str):
val = hglib.tounicode(val)
s.setValue('sync/' + opt, val)
......@@ -433,7 +433,7 @@ class SyncWidget(QWidget, qtlib.TaskWidget):
self.urlChanged()
opts = []
for opt, value in self.opts.iteritems():
for opt, value in self.opts.items():
if value is True:
opts.append('--'+opt)
elif value:
......@@ -1145,7 +1145,7 @@ class PostPullDialog(QDialog):
sd.exec_()
def getValue(self):
return next(iter(op for op, chk in self._opchecks.iteritems()
return next(iter(op for op, chk in self._opchecks.items()
if chk.isChecked()))
def accept(self):
......
......@@ -189,7 +189,7 @@ class RepoWatcher(QObject):
def _addMissingPaths(self):
'Add files to watcher that may have been added or replaced'
existing = [f for f, (_flag, watched) in self._filesmap.iteritems()
existing = [f for f, (_flag, watched) in self._filesmap.items()
if watched and f in self._laststats]
files = [unicode(f) for f in self._fswatcher.files()]
for f in existing:
......@@ -291,7 +291,7 @@ class RepoWatcher(QObject):
pass
curdata = {}
for readmeth, (_flag, path) in self._datamap.iteritems():
for readmeth, (_flag, path) in self._datamap.items():
if path not in targetpaths:
continue
last = self._laststats.get(path, -1)
......@@ -308,13 +308,13 @@ class RepoWatcher(QObject):
def _calculateChangeFlags(self, curstats, curdata):
changeflags = 0
for path, (flag, _watched) in self._filesmap.iteritems():
for path, (flag, _watched) in self._filesmap.items():
last = self._laststats.get(path, -1)
cur = curstats.get(path, -1)
if last != cur:
self._ui.debug(' stat: %s (%r -> %r)\n' % (path, last, cur))
changeflags |= flag
for readmeth, (flag, _path) in self._datamap.iteritems():
for readmeth, (flag, _path) in self._datamap.items():
last = self._lastdata.get(readmeth)
cur = curdata.get(readmeth)
if last != cur:
......
......@@ -155,7 +155,7 @@ class StripWidget(cmdui.AbstractCmdWidget):
def runCommand(self):
opts = {'verbose': True}
opts.update((n, w.isChecked()) for n, w in self._optchks.iteritems())
opts.update((n, w.isChecked()) for n, w in self._optchks.items())
wc = self.repo[None]
wcparents = wc.parents()
......
......@@ -1079,7 +1079,7 @@ def buildcmdargs(name, *args, **opts):
['tag', u'--message=\xc1', u'\xc0']
"""
fullargs = [_stringify(name)]
for k, v in opts.iteritems():
for k, v in opts.items():
if v is None:
continue
......
......@@ -247,7 +247,7 @@ class _wconfig(object):
getattr(ini, 'new_namespace'))
return newns(section)
for k, v in self._sections.iteritems():
for k, v in self._sections.items():
v._replaylog(getsection(ini, k))
def __getattr__(self, name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment