Comments
Patch
@@ -25,7 +25,9 @@ allowsymbolimports = (
)
# Whitelist of symbols that can be directly imported.
-directsymbols = ()
+directsymbols = (
+ 'demandimport',
+)
# Modules that must be aliased because they are commonly confused with
# common variables and can create aliasing and readability issues.
new file mode 100644
@@ -0,0 +1,23 @@
+# hgdemandimport - global demand-loading of modules for Mercurial
+#
+# Copyright 2017 Facebook Inc.
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+'''demandimport - automatic demand-loading of modules'''
+
+# This is in a separate package from mercurial because in Python 3,
+# demand loading is per-package. Keeping demandimport in the mercurial package
+# would disable demand loading for any modules in mercurial.
+
+from __future__ import absolute_import
+
+from . import demandimportpy2 as demandimport
+
+# Re-export.
+ignore = demandimport.ignore
+isenabled = demandimport.isenabled
+enable = demandimport.enable
+disable = demandimport.disable
+deactivated = demandimport.deactivated
rename from mercurial/demandimport.py
rename to hgdemandimport/demandimportpy2.py
@@ -9,6 +9,10 @@ from __future__ import absolute_import
import sys
+# Allow 'from mercurial import demandimport' to keep working.
+import hgdemandimport
+demandimport = hgdemandimport
+
__all__ = []
# Python 3 uses a custom module loader that transforms source code between
@@ -587,7 +587,8 @@ packages = ['mercurial',
'mercurial.pure',
'hgext', 'hgext.convert', 'hgext.fsmonitor',
'hgext.fsmonitor.pywatchman', 'hgext.highlight',
- 'hgext.largefiles', 'hgext.zeroconf', 'hgext3rd']
+ 'hgext.largefiles', 'hgext.zeroconf', 'hgext3rd',
+ 'hgdemandimport']
common_depends = ['mercurial/bitmanipulation.h',
'mercurial/compat.h',
@@ -793,7 +794,7 @@ setup(name='mercurial',
package_data=packagedata,
cmdclass=cmdclass,
distclass=hgdist,
- options={'py2exe': {'packages': ['hgext', 'email']},
+ options={'py2exe': {'packages': ['hgdemandimport', 'hgext', 'email']},
'bdist_mpkg': {'zipdist': False,
'license': 'COPYING',
'readme': 'contrib/macosx/Readme.html',