diff mercurial/__init__.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 74802979dd9d
children d783f945a701
line wrap: on
line diff
--- a/mercurial/__init__.py	Sun Oct 06 17:59:15 2019 -0400
+++ b/mercurial/__init__.py	Sun Oct 06 19:25:18 2019 -0400
@@ -31,7 +31,7 @@
 
         def find_spec(self, fullname, path, target=None):
             # Only handle Mercurial-related modules.
-            if not fullname.startswith(('mercurial.', 'hgext.')):
+            if not fullname.startswith('mercurial.'):
                 return None
             # don't try to parse binary
             if fullname.startswith('mercurial.cext.'):
@@ -46,9 +46,6 @@
             # don't try and mangle it
             if fullname.startswith('mercurial.rustext'):
                 return None
-            # pywatchman is already dual-version clean, don't try and mangle it
-            if fullname.startswith('hgext.fsmonitor.pywatchman'):
-                return None
 
             # Try to find the module using other registered finders.
             spec = None
@@ -131,7 +128,7 @@
     # ``replacetoken`` or any mechanism that changes semantics of module
     # loading is changed. Otherwise cached bytecode may get loaded without
     # the new transformation mechanisms applied.
-    BYTECODEHEADER = b'HG\x00\x15'
+    BYTECODEHEADER = b'HG\x00\x16'
 
     class hgloader(importlib.machinery.SourceFileLoader):
         """Custom module loader that transforms source code.