Mercurial > hg-stable
changeset 7622:4dd7b28003d2
use dict.iteritems() rather than dict.items()
This should be faster and more future-proof. Calls where the result is to be
sorted using util.sort() have been left unchanged. Calls to .items() on
configparser objects have been left as-is, too.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 12 Jan 2009 09:16:03 +0100 |
parents | 6d891df43a5f |
children | 03007ad08027 |
files | hgext/bookmarks.py hgext/rebase.py mercurial/commands.py mercurial/copies.py mercurial/filelog.py mercurial/hgweb/webcommands.py mercurial/hgweb/wsgicgi.py mercurial/ignore.py mercurial/keepalive.py mercurial/localrepo.py mercurial/lsprof.py mercurial/merge.py mercurial/sshrepo.py mercurial/verify.py |
diffstat | 14 files changed, 25 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/bookmarks.py Mon Jan 12 09:07:02 2009 +0100 +++ b/hgext/bookmarks.py Mon Jan 12 09:16:03 2009 +0100 @@ -67,7 +67,7 @@ if current(repo) not in refs: setcurrent(repo, None) file = repo.opener('bookmarks', 'w+') - for refspec, node in refs.items(): + for refspec, node in refs.iteritems(): file.write("%s %s\n" % (hex(node), refspec)) file.close() @@ -206,7 +206,7 @@ revisions = _revstostrip(repo.changelog, node) marks = parse(repo) update = [] - for mark, n in marks.items(): + for mark, n in marks.iteritems(): if repo.changelog.rev(n) in revisions: update.append(mark) oldstrip(ui, repo, node, backup)
--- a/hgext/rebase.py Mon Jan 12 09:07:02 2009 +0100 +++ b/hgext/rebase.py Mon Jan 12 09:16:03 2009 +0100 @@ -281,7 +281,7 @@ f.write(repo[target].hex() + '\n') f.write(repo[external].hex() + '\n') f.write('%d\n' % int(collapse)) - for d, v in state.items(): + for d, v in state.iteritems(): oldrev = repo[d].hex() newrev = repo[v].hex() f.write("%s:%s\n" % (oldrev, newrev))
--- a/mercurial/commands.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/commands.py Mon Jan 12 09:16:03 2009 +0100 @@ -788,7 +788,7 @@ """show the contents of the current dirstate""" timestr = "" showdate = not nodates - for file_, ent in util.sort(repo.dirstate._map.items()): + for file_, ent in util.sort(repo.dirstate._map.iteritems()): if showdate: if ent[3] == -1: # Pad or slice to locale representation @@ -1348,7 +1348,7 @@ def helplist(header, select=None): h = {} cmds = {} - for c, e in table.items(): + for c, e in table.iteritems(): f = c.split("|", 1)[0] if select and not select(f): continue @@ -2746,7 +2746,7 @@ if node2 is None: added = stat[0] + stat[1] # merged? - for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items(): + for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems(): if k in added: copy[k] = v elif v in added:
--- a/mercurial/copies.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/copies.py Mon Jan 12 09:16:03 2009 +0100 @@ -189,7 +189,7 @@ # examine each file copy for a potential directory move, which is # when all the files in a directory are moved to a new directory - for dst, src in fullcopy.items(): + for dst, src in fullcopy.iteritems(): dsrc, ddst = _dirname(src), _dirname(dst) if dsrc in invalid: # already seen to be uninteresting
--- a/mercurial/filelog.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/filelog.py Mon Jan 12 09:16:03 2009 +0100 @@ -50,7 +50,7 @@ if meta or text.startswith('\1\n'): mt = "" if meta: - mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ] + mt = ["%s: %s\n" % (k, v) for k, v in meta.iteritems()] text = "\1\n%s\1\n%s" % ("".join(mt), text) return self.addrevision(text, transaction, link, p1, p2)
--- a/mercurial/hgweb/webcommands.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/hgweb/webcommands.py Mon Jan 12 09:16:03 2009 +0100 @@ -275,7 +275,7 @@ l = len(path) abspath = "/" + path - for f, n in mf.items(): + for f, n in mf.iteritems(): if f[:l] != path: continue remain = f[l:] @@ -386,7 +386,7 @@ parity = paritygen(web.stripecount) b = web.repo.branchtags() - l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()] + l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()] for r,n,t in util.sort(l): yield {'parity': parity.next(), 'branch': t,
--- a/mercurial/hgweb/wsgicgi.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/hgweb/wsgicgi.py Mon Jan 12 09:16:03 2009 +0100 @@ -15,7 +15,7 @@ util.set_binary(sys.stdin) util.set_binary(sys.stdout) - environ = dict(os.environ.items()) + environ = dict(os.environ.iteritems()) environ.setdefault('PATH_INFO', '') if '.cgi' in environ['PATH_INFO']: environ['PATH_INFO'] = environ['PATH_INFO'].split('.cgi', 1)[1]
--- a/mercurial/ignore.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/ignore.py Mon Jan 12 09:16:03 2009 +0100 @@ -60,7 +60,7 @@ warn(_("%s: ignoring invalid syntax '%s'\n") % (f, s)) continue pat = syntax + line - for s, rels in syntaxes.items(): + for s, rels in syntaxes.iteritems(): if line.startswith(rels): pat = line break @@ -83,7 +83,7 @@ util.matcher(root, inc=allpats, src='.hgignore')) except util.Abort: # Re-raise an exception where the src is the right file - for f, patlist in pats.items(): + for f, patlist in pats.iteritems(): files, ignorefunc, anypats = ( util.matcher(root, inc=patlist, src=f))
--- a/mercurial/keepalive.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/keepalive.py Mon Jan 12 09:16:03 2009 +0100 @@ -197,7 +197,7 @@ def close_all(self): """close all open connections""" - for host, conns in self._cm.get_all().items(): + for host, conns in self._cm.get_all().iteritems(): for h in conns: self._cm.remove(h) h.close()
--- a/mercurial/localrepo.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/localrepo.py Mon Jan 12 09:16:03 2009 +0100 @@ -265,7 +265,7 @@ h.append(n) filetags[key] = (bin_n, h) - for k, nh in filetags.items(): + for k, nh in filetags.iteritems(): if k not in globaltags: globaltags[k] = nh tagtypes[k] = tagtype @@ -301,7 +301,7 @@ self.tagscache = {} self._tagstypecache = {} - for k,nh in globaltags.items(): + for k, nh in globaltags.iteritems(): n = nh[0] if n != nullid: self.tagscache[k] = n @@ -343,7 +343,7 @@ def tagslist(self): '''return a list of tags ordered by revision''' l = [] - for t, n in self.tags().items(): + for t, n in self.tags().iteritems(): try: r = self.changelog.rev(n) except: @@ -355,7 +355,7 @@ '''return the tags associated with a node''' if not self.nodetagscache: self.nodetagscache = {} - for t, n in self.tags().items(): + for t, n in self.tags().iteritems(): self.nodetagscache.setdefault(n, []).append(t) return self.nodetagscache.get(node, []) @@ -388,7 +388,7 @@ # the branch cache is stored on disk as UTF-8, but in the local # charset internally - for k, v in partial.items(): + for k, v in partial.iteritems(): self.branchcache[util.tolocal(k)] = v self._ubranchcache = partial return self.branchcache @@ -1756,7 +1756,7 @@ # we only need to see a diff. deltamf = mnfst.readdelta(mnfstnode) # For each line in the delta - for f, fnode in deltamf.items(): + for f, fnode in deltamf.iteritems(): f = changedfiles.get(f, None) # And if the file is in the list of files we care # about.
--- a/mercurial/lsprof.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/lsprof.py Mon Jan 12 09:16:03 2009 +0100 @@ -88,7 +88,7 @@ try: mname = _fn2mod[code.co_filename] except KeyError: - for k, v in sys.modules.items(): + for k, v in sys.modules.iteritems(): if v is None: continue if not hasattr(v, '__file__'):
--- a/mercurial/merge.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/merge.py Mon Jan 12 09:16:03 2009 +0100 @@ -36,7 +36,7 @@ def _write(self): f = self._repo.opener("merge/state", "w") f.write(hex(self._local) + "\n") - for d, v in self._state.items(): + for d, v in self._state.iteritems(): f.write("\0".join([d] + v) + "\n") def add(self, fcl, fco, fca, fd, flags): hash = util.sha1(fcl.path()).hexdigest() @@ -166,7 +166,7 @@ dirs = repo.ui.configbool("merge", "followdirs", True) copy, diverge = copies.copies(repo, p1, p2, pa, dirs) copied = dict.fromkeys(copy.values()) - for of, fl in diverge.items(): + for of, fl in diverge.iteritems(): act("divergent renames", "dr", of, fl) # Compare manifests
--- a/mercurial/sshrepo.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/sshrepo.py Mon Jan 12 09:16:03 2009 +0100 @@ -115,7 +115,7 @@ def do_cmd(self, cmd, **args): self.ui.debug(_("sending %s command\n") % cmd) self.pipeo.write("%s\n" % cmd) - for k, v in args.items(): + for k, v in args.iteritems(): self.pipeo.write("%s %d\n" % (k, len(v))) self.pipeo.write(v) self.pipeo.flush()
--- a/mercurial/verify.py Mon Jan 12 09:07:02 2009 +0100 +++ b/mercurial/verify.py Mon Jan 12 09:16:03 2009 +0100 @@ -220,7 +220,7 @@ # cross-check if f in filenodes: - fns = [(mf.linkrev(l), n) for n,l in filenodes[f].items()] + fns = [(mf.linkrev(l), n) for n,l in filenodes[f].iteritems()] for lr, node in util.sort(fns): err(lr, _("%s in manifests not found") % short(node), f)