# HG changeset patch
# User timeless <timel...@mozdev.org>
# Date 1474429251 0
#      Wed Sep 21 03:40:51 2016 +0000
# Node ID 32a4cb17f935c570817249721401e0d62033987d
# Parent  982fe7cdb28bb263a96b1bc2c9c3b8aedb025ab6
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r 
32a4cb17f935
demandimport: refactor processfromlist to ensure consistent handling

The next changeset will add a slow path for modules where certain
properties should be treated as not present.

In order to ensure that the codepath is handled the same for
absolute_import and relative import, this code should be in a single
location.

diff -r 982fe7cdb28b -r 32a4cb17f935 mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 03:39:37 2016 +0000
+++ b/mercurial/demandimport.py Wed Sep 21 03:40:51 2016 +0000
@@ -220,6 +220,12 @@
                 mod = getattr(mod, comp)
             return mod
 
+        def processfromlist(mod, name, fromlist):
+            # call processfromitem for each item in fromlist
+            if True:
+                for x in fromlist:
+                    processfromitem(mod, x)
+
         if level >= 0:
             if name:
                 # "from a import b" or "from .a import b" style
@@ -242,8 +248,7 @@
                 mod = _hgextimport(_origimport, name, globals, locals,
                                    level=level)
 
-            for x in fromlist:
-                processfromitem(mod, x)
+            processfromlist(mod, name, fromlist)
 
             return mod
 
@@ -251,9 +256,7 @@
         # party modules. So handle level == -1.
         mod = _hgextimport(_origimport, name, globals, locals)
         mod = chainmodules(mod, name)
-
-        for x in fromlist:
-            processfromitem(mod, x)
+        processfromlist(mod, name, fromlist)
 
         return mod
 
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to