##// END OF EJS Templates
py3: define and use pycompat.itervalues()...
Gregory Szorc -
r43374:74802979 default
parent child Browse files
Show More
@@ -213,7 +213,7 b' def analyze(ui, repo, *revs, **opts):'
213 for filename, mar, lineadd, lineremove, isbin in parsegitdiff(diff):
213 for filename, mar, lineadd, lineremove, isbin in parsegitdiff(diff):
214 if isbin:
214 if isbin:
215 continue
215 continue
216 added = sum(lineadd.itervalues(), 0)
216 added = sum(pycompat.itervalues(lineadd), 0)
217 if mar == 'm':
217 if mar == 'm':
218 if added and lineremove:
218 if added and lineremove:
219 lineschanged[
219 lineschanged[
@@ -164,7 +164,7 b' def _mergeentriesiter(*iterables, **kwar'
164 pass
164 pass
165
165
166 while iterable_map:
166 while iterable_map:
167 value, key, it = order(iterable_map.itervalues())
167 value, key, it = order(pycompat.itervalues(iterable_map))
168 yield value
168 yield value
169 try:
169 try:
170 iterable_map[key][0] = next(it)
170 iterable_map[key][0] = next(it)
@@ -2288,7 +2288,7 b' def summaryhook(ui, repo):'
2288 msg = _(b'rebase: (use "hg rebase --abort" to clear broken state)\n')
2288 msg = _(b'rebase: (use "hg rebase --abort" to clear broken state)\n')
2289 ui.write(msg)
2289 ui.write(msg)
2290 return
2290 return
2291 numrebased = len([i for i in state.itervalues() if i >= 0])
2291 numrebased = len([i for i in pycompat.itervalues(state) if i >= 0])
2292 # i18n: column positioning for "hg summary"
2292 # i18n: column positioning for "hg summary"
2293 ui.write(
2293 ui.write(
2294 _(b'rebase: %s, %s (rebase --continue)\n')
2294 _(b'rebase: %s, %s (rebase --continue)\n')
@@ -10,6 +10,7 b' from __future__ import absolute_import'
10 from mercurial import (
10 from mercurial import (
11 extensions,
11 extensions,
12 hg,
12 hg,
13 pycompat,
13 sshpeer,
14 sshpeer,
14 util,
15 util,
15 )
16 )
@@ -59,7 +60,7 b' class connectionpool(object):'
59 return conn
60 return conn
60
61
61 def close(self):
62 def close(self):
62 for pathpool in self._pool.itervalues():
63 for pathpool in pycompat.itervalues(self._pool):
63 for conn in pathpool:
64 for conn in pathpool:
64 conn.close()
65 conn.close()
65 del pathpool[:]
66 del pathpool[:]
@@ -207,7 +207,7 b' def verifyremotefilelog(ui, path, **opts'
207 continue
207 continue
208 filepath = os.path.join(root, file)
208 filepath = os.path.join(root, file)
209 size, firstnode, mapping = parsefileblob(filepath, decompress)
209 size, firstnode, mapping = parsefileblob(filepath, decompress)
210 for p1, p2, linknode, copyfrom in mapping.itervalues():
210 for p1, p2, linknode, copyfrom in pycompat.itervalues(mapping):
211 if linknode == nullid:
211 if linknode == nullid:
212 actualpath = os.path.relpath(root, path)
212 actualpath = os.path.relpath(root, path)
213 key = fileserverclient.getcachekey(
213 key = fileserverclient.getcachekey(
@@ -598,7 +598,7 b' class repacker(object):'
598 maxchainlen = ui.configint(b'packs', b'maxchainlen', 1000)
598 maxchainlen = ui.configint(b'packs', b'maxchainlen', 1000)
599
599
600 byfile = {}
600 byfile = {}
601 for entry in ledger.entries.itervalues():
601 for entry in pycompat.itervalues(ledger.entries):
602 if entry.datasource:
602 if entry.datasource:
603 byfile.setdefault(entry.filename, {})[entry.node] = entry
603 byfile.setdefault(entry.filename, {})[entry.node] = entry
604
604
@@ -753,7 +753,7 b' class repacker(object):'
753 ui = self.repo.ui
753 ui = self.repo.ui
754
754
755 byfile = {}
755 byfile = {}
756 for entry in ledger.entries.itervalues():
756 for entry in pycompat.itervalues(ledger.entries):
757 if entry.historysource:
757 if entry.historysource:
758 byfile.setdefault(entry.filename, {})[entry.node] = entry
758 byfile.setdefault(entry.filename, {})[entry.node] = entry
759
759
@@ -100,7 +100,7 b' class transplants(object):'
100 if not os.path.isdir(self.path):
100 if not os.path.isdir(self.path):
101 os.mkdir(self.path)
101 os.mkdir(self.path)
102 fp = self.opener(self.transplantfile, b'w')
102 fp = self.opener(self.transplantfile, b'w')
103 for list in self.transplants.itervalues():
103 for list in pycompat.itervalues(self.transplants):
104 for t in list:
104 for t in list:
105 l, r = map(nodemod.hex, (t.lnode, t.rnode))
105 l, r = map(nodemod.hex, (t.lnode, t.rnode))
106 fp.write(l + b':' + r + b'\n')
106 fp.write(l + b':' + r + b'\n')
@@ -117,7 +117,7 b' if sys.version_info[0] >= 3:'
117
117
118 # It changes iteritems/values to items/values as they are not
118 # It changes iteritems/values to items/values as they are not
119 # present in Python 3 world.
119 # present in Python 3 world.
120 if fn in ('iteritems', 'itervalues') and not (
120 if fn == 'iteritems' and not (
121 tokens[i - 1].type == token.NAME
121 tokens[i - 1].type == token.NAME
122 and tokens[i - 1].string == 'def'
122 and tokens[i - 1].string == 'def'
123 ):
123 ):
@@ -131,7 +131,7 b' if sys.version_info[0] >= 3:'
131 # ``replacetoken`` or any mechanism that changes semantics of module
131 # ``replacetoken`` or any mechanism that changes semantics of module
132 # loading is changed. Otherwise cached bytecode may get loaded without
132 # loading is changed. Otherwise cached bytecode may get loaded without
133 # the new transformation mechanisms applied.
133 # the new transformation mechanisms applied.
134 BYTECODEHEADER = b'HG\x00\x14'
134 BYTECODEHEADER = b'HG\x00\x15'
135
135
136 class hgloader(importlib.machinery.SourceFileLoader):
136 class hgloader(importlib.machinery.SourceFileLoader):
137 """Custom module loader that transforms source code.
137 """Custom module loader that transforms source code.
@@ -91,7 +91,7 b' class BranchMapCache(object):'
91 clbranchinfo = cl.branchinfo
91 clbranchinfo = cl.branchinfo
92 rbheads = []
92 rbheads = []
93 closed = []
93 closed = []
94 for bheads in remotebranchmap.itervalues():
94 for bheads in pycompat.itervalues(remotebranchmap):
95 rbheads += bheads
95 rbheads += bheads
96 for h in bheads:
96 for h in bheads:
97 r = clrev(h)
97 r = clrev(h)
@@ -350,7 +350,7 b' class branchcache(object):'
350 def iterheads(self):
350 def iterheads(self):
351 """ returns all the heads """
351 """ returns all the heads """
352 self._verifyall()
352 self._verifyall()
353 return self._entries.itervalues()
353 return pycompat.itervalues(self._entries)
354
354
355 def copy(self):
355 def copy(self):
356 """return an deep copy of the branchcache object"""
356 """return an deep copy of the branchcache object"""
@@ -607,7 +607,7 b' def _fetchfiles(repo, tr, remote, fnodes'
607 progress = repo.ui.makeprogress(
607 progress = repo.ui.makeprogress(
608 _(b'files'),
608 _(b'files'),
609 unit=_(b'chunks'),
609 unit=_(b'chunks'),
610 total=sum(len(v) for v in fnodes.itervalues()),
610 total=sum(len(v) for v in pycompat.itervalues(fnodes)),
611 )
611 )
612
612
613 # TODO make batch size configurable
613 # TODO make batch size configurable
@@ -706,7 +706,7 b' def _fetchfilesfromcsets('
706 progress = repo.ui.makeprogress(
706 progress = repo.ui.makeprogress(
707 _(b'files'),
707 _(b'files'),
708 unit=_(b'chunks'),
708 unit=_(b'chunks'),
709 total=sum(len(v) for v in fnodes.itervalues()),
709 total=sum(len(v) for v in pycompat.itervalues(fnodes)),
710 )
710 )
711
711
712 commandmeta = remote.apidescriptor[b'commands'][b'filesdata']
712 commandmeta = remote.apidescriptor[b'commands'][b'filesdata']
@@ -1763,7 +1763,7 b' class localrepository(object):'
1763 nodetagscache = {}
1763 nodetagscache = {}
1764 for t, n in self._tagscache.tags.iteritems():
1764 for t, n in self._tagscache.tags.iteritems():
1765 nodetagscache.setdefault(n, []).append(t)
1765 nodetagscache.setdefault(n, []).append(t)
1766 for tags in nodetagscache.itervalues():
1766 for tags in pycompat.itervalues(nodetagscache):
1767 tags.sort()
1767 tags.sort()
1768 self._tagscache.nodetagscache = nodetagscache
1768 self._tagscache.nodetagscache = nodetagscache
1769 return self._tagscache.nodetagscache.get(node, [])
1769 return self._tagscache.nodetagscache.get(node, [])
@@ -702,7 +702,7 b' class mergestate(object):'
702 """return counts for updated, merged and removed files in this
702 """return counts for updated, merged and removed files in this
703 session"""
703 session"""
704 updated, merged, removed = 0, 0, 0
704 updated, merged, removed = 0, 0, 0
705 for r, action in self._results.itervalues():
705 for r, action in pycompat.itervalues(self._results):
706 if r is None:
706 if r is None:
707 updated += 1
707 updated += 1
708 elif r == 0:
708 elif r == 0:
@@ -1331,7 +1331,11 b' the hunk is left unchanged.'
1331 fixoffset += chunk.removed - chunk.added
1331 fixoffset += chunk.removed - chunk.added
1332 return (
1332 return (
1333 sum(
1333 sum(
1334 [h for h in applied.itervalues() if h[0].special() or len(h) > 1],
1334 [
1335 h
1336 for h in pycompat.itervalues(applied)
1337 if h[0].special() or len(h) > 1
1338 ],
1335 [],
1339 [],
1336 ),
1340 ),
1337 {},
1341 {},
@@ -337,6 +337,7 b' if ispy3:'
337 ret = shlex.split(s.decode('latin-1'), comments, posix)
337 ret = shlex.split(s.decode('latin-1'), comments, posix)
338 return [a.encode('latin-1') for a in ret]
338 return [a.encode('latin-1') for a in ret]
339
339
340 itervalues = lambda x: x.values()
340
341
341 else:
342 else:
342 import cStringIO
343 import cStringIO
@@ -413,6 +414,7 b' else:'
413 ziplist = zip
414 ziplist = zip
414 rawinput = raw_input
415 rawinput = raw_input
415 getargspec = inspect.getargspec
416 getargspec = inspect.getargspec
417 itervalues = lambda x: x.itervalues()
416
418
417 isjython = sysplatform.startswith(b'java')
419 isjython = sysplatform.startswith(b'java')
418
420
@@ -475,7 +475,7 b' class SiteStats(object):'
475 if i == 0:
475 if i == 0:
476 sitestat.addself()
476 sitestat.addself()
477
477
478 return [s for s in stats.itervalues()]
478 return [s for s in pycompat.itervalues(stats)]
479
479
480
480
481 class DisplayFormats:
481 class DisplayFormats:
@@ -744,7 +744,7 b' def display_hotpath(data, fp, limit=0.05'
744 site = node.site
744 site = node.site
745 visiblechildren = [
745 visiblechildren = [
746 c
746 c
747 for c in node.children.itervalues()
747 for c in pycompat.itervalues(node.children)
748 if c.count >= (limit * root.count)
748 if c.count >= (limit * root.count)
749 ]
749 ]
750 if site:
750 if site:
@@ -752,7 +752,7 b' def display_hotpath(data, fp, limit=0.05'
752 filename = b''
752 filename = b''
753 function = b''
753 function = b''
754 if len(node.children) > 0:
754 if len(node.children) > 0:
755 childsite = list(node.children.itervalues())[0].site
755 childsite = list(pycompat.itervalues(node.children))[0].site
756 filename = (childsite.filename() + b':').ljust(15)
756 filename = (childsite.filename() + b':').ljust(15)
757 function = childsite.function
757 function = childsite.function
758
758
@@ -777,7 +777,9 b' def display_hotpath(data, fp, limit=0.05'
777 )
777 )
778
778
779 finalstring = liststring + codestring
779 finalstring = liststring + codestring
780 childrensamples = sum([c.count for c in node.children.itervalues()])
780 childrensamples = sum(
781 [c.count for c in pycompat.itervalues(node.children)]
782 )
781 # Make frames that performed more than 10% of the operation red
783 # Make frames that performed more than 10% of the operation red
782 if node.count - childrensamples > (0.1 * root.count):
784 if node.count - childrensamples > (0.1 * root.count):
783 finalstring = b'\033[91m' + finalstring + b'\033[0m'
785 finalstring = b'\033[91m' + finalstring + b'\033[0m'
@@ -1966,7 +1966,7 b' class ui(object):'
1966 if not self._loggers:
1966 if not self._loggers:
1967 return
1967 return
1968 activeloggers = [
1968 activeloggers = [
1969 l for l in self._loggers.itervalues() if l.tracked(event)
1969 l for l in pycompat.itervalues(self._loggers) if l.tracked(event)
1970 ]
1970 ]
1971 if not activeloggers:
1971 if not activeloggers:
1972 return
1972 return
@@ -67,7 +67,7 b" def buildprobtable(fp, cmd='hg manifest "
67 counts[c] += 1
67 counts[c] += 1
68 for c in '\r/\n':
68 for c in '\r/\n':
69 counts.pop(c, None)
69 counts.pop(c, None)
70 t = sum(counts.itervalues()) / 100.0
70 t = sum(pycompat.itervalues(counts)) / 100.0
71 fp.write('probtable = (')
71 fp.write('probtable = (')
72 for i, (k, v) in enumerate(
72 for i, (k, v) in enumerate(
73 sorted(counts.items(), key=lambda x: x[1], reverse=True)
73 sorted(counts.items(), key=lambda x: x[1], reverse=True)
General Comments 0
You need to be logged in to leave comments. Login now