manifest: use itertools.chain() instead of + for Python 3 compat
authorAugie Fackler <raf@durin42.com>
Sun, 28 May 2017 21:29:58 -0400
changeset 32536 aa333c1982ab
parent 32535 260a6f715bd2
child 32537 044f3d7eb9ae
manifest: use itertools.chain() instead of + for Python 3 compat This is all pure-Python code, so I'm not too worried about perf here, but we can come back and fix it should it be a problem. With this change, the manifest code passes most unit tests on Python 3 (once the tests are corrected with many b prefixes. I've got a little more to sort out there and then I'll mail that change too.
mercurial/manifest.py
--- a/mercurial/manifest.py	Sun May 28 21:29:15 2017 -0400
+++ b/mercurial/manifest.py	Sun May 28 21:29:58 2017 -0400
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 import heapq
+import itertools
 import os
 import struct
 
@@ -779,7 +780,8 @@
 
     def iterentries(self):
         self._load()
-        for p, n in sorted(self._dirs.items() + self._files.items()):
+        for p, n in sorted(itertools.chain(self._dirs.items(),
+                                           self._files.items())):
             if p in self._files:
                 yield self._subpath(p), n, self._flags.get(p, '')
             else:
@@ -788,7 +790,8 @@
 
     def iteritems(self):
         self._load()
-        for p, n in sorted(self._dirs.items() + self._files.items()):
+        for p, n in sorted(itertools.chain(self._dirs.items(),
+                                           self._files.items())):
             if p in self._files:
                 yield self._subpath(p), n
             else:
@@ -797,7 +800,7 @@
 
     def iterkeys(self):
         self._load()
-        for p in sorted(self._dirs.keys() + self._files.keys()):
+        for p in sorted(itertools.chain(self._dirs, self._files)):
             if p in self._files:
                 yield self._subpath(p)
             else: