[meld] vc: Remove complicated import mechanism made irrelevant by our hacks



commit 38c7d357053860b8fdc2e9e608b96e1b602148a3
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Dec 18 07:21:34 2017 +1000

    vc: Remove complicated import mechanism made irrelevant by our hacks
    
    Because of cx_Freeze, we need to have all these imports inline anyway.
    Honestly, it's not that big a deal to just import them, so instead of
    adding yet another layer of weird, let's just get rid of the dynamic
    imports entirely.

 meld/vc/__init__.py | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/meld/vc/__init__.py b/meld/vc/__init__.py
index c6999542..d69e288b 100644
--- a/meld/vc/__init__.py
+++ b/meld/vc/__init__.py
@@ -23,29 +23,16 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import importlib
-from . import _null
+from . import git, mercurial, bzr, svn, darcs, _null
 
-# FIXME: This is a horrible hack to help cx_Freeze pick up these plugins when
-# freezing the distributable package.
-from . import git, mercurial, bzr, svn, darcs
-
-# Tuple with module name and vc.NAME field, ordered according to best-guess
-# as to which VC a user is likely to want by default in a multiple-VC situation
-vc_names = (
-    "git",
-    "mercurial",
-    "bzr",
-    "svn",
-    "darcs",
-)
-
-_plugins = [importlib.import_module("." + vc, __name__) for vc in vc_names]
+# Tuple of plugins, ordered according to best-guess as to which VC a
+# user is likely to want by default in a multiple-VC situation.
+VC_PLUGINS = (git, mercurial, bzr, svn, darcs)
 
 
 def get_plugins_metadata():
     ret = []
-    for p in _plugins:
+    for p in VC_PLUGINS:
         # Some plugins have VC_DIR=None until instantiated
         if p.Vc.VC_DIR:
             ret.append(p.Vc.VC_DIR)
@@ -69,7 +56,7 @@ def get_vcs(location):
 
     vcs = []
     max_depth = 0
-    for plugin in _plugins:
+    for plugin in VC_PLUGINS:
         root, location = plugin.Vc.is_in_repo(location)
         if not root:
             continue


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]