D6614: py3: don't run source transformer on hgext3rd (extensions)

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Jul 8 12:52:53 EDT 2019

martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

  It's unclear why the source transformer runs on hgext3rd. It's been
  like that since it was introduced in 1c22400db72d <https://phab.mercurial-scm.org/rHG1c22400db72de4bbeb992fde534c0abbe1367b03> (mercurial:
  implement a source transforming module loader on Python 3,
  2016-07-04), and that commit didn't say anything about it (but it says
  that it doesn't have "support [...] for extensions").
  I find that the current handling of hgext3rd just makes it harder to
  convert extensions to Python 3. It makes you convert a bunch of
  strings passed to getattr() and kwargs[] to r'' that could otherwise
  have been left alone. It's also really confusing that the source
  transformer runs when you import the extension as "extensions.foo=",
  but not as "extension.foo=/some/path".
  I suppose there is small number of (very simple) extensions that would
  have worked without this patch that would now be broken. It seems okay
  to me to break those.

  rHG Mercurial




diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -73,3 +73,7 @@
    `addunfinished()` in `state` module.
  * `cmdutil.checkunfinished()` now includes detection for merge too.
+ * We used to automatically attempt to make extensions compatible with
+   Python 3 (by translating their source code while loading it). We no
+   longer do that.
diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -29,7 +29,7 @@
         """A sys.meta_path finder that uses a custom module loader."""
         def find_spec(self, fullname, path, target=None):
             # Only handle Mercurial-related modules.
-            if not fullname.startswith(('mercurial.', 'hgext.', 'hgext3rd.')):
+            if not fullname.startswith(('mercurial.', 'hgext.')):
                 return None
             # don't try to parse binary
             if fullname.startswith('mercurial.cext.'):

To: martinvonz, #hg-reviewers
Cc: mercurial-devel

More information about the Mercurial-devel mailing list