hgext: officially turn 'hgext' into a namespace package
Actually since Python 2.3, there is some way to turn top level package into
"namespace package" so that multiple subpackage installed in different part of
the path can still be imported transparently. This feature was previously
thought (at least by myself) to be only provided by some setuptool black magic.
Turning hgext into such namespace package allows third extensions to install
themselves inside the "hgext" namespace package to avoid polluting the global
python module namespace. They will now be able to do so without making it a pain
to use a Mercurial "installed" in a different way/location than these
extensions.
The only constrains is that the extension ship a 'hgext/__init__.py' containing
the same call to 'pkgutil.extend_path' and nothing else. This seems realistic.
The main question that remains is: should we introduce a dedicated namespace for
third party extension (hgext3rd?) to make a clearer distinction between what is
officially supported and what is not? If so, this will be introduced in a follow
up patch.
--- a/hgext/__init__.py Fri Mar 11 15:24:27 2016 -0600
+++ b/hgext/__init__.py Sat Feb 27 12:56:26 2016 +0100
@@ -1,1 +1,3 @@
-# placeholder
+from __future__ import absolute_import
+import pkgutil
+__path__ = pkgutil.extend_path(__path__, __name__)
--- a/tests/test-check-py3-compat.t Fri Mar 11 15:24:27 2016 -0600
+++ b/tests/test-check-py3-compat.t Sat Feb 27 12:56:26 2016 +0100
@@ -19,7 +19,6 @@
doc/check-seclevel.py not using absolute_import
doc/gendoc.py not using absolute_import
doc/hgmanpage.py not using absolute_import
- hgext/__init__.py not using absolute_import
hgext/color.py not using absolute_import
hgext/eol.py not using absolute_import
hgext/extdiff.py not using absolute_import