eric7/VCS/__init__.py

branch
eric7
changeset 8312
800c432b34c8
parent 7923
91e843545d9a
child 8356
68ec9c3d4de5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eric7/VCS/__init__.py	Sat May 15 18:45:04 2021 +0200
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing the general part of the interface to version control
+systems.
+
+The general part of the VCS interface defines classes to implement common
+dialogs. These are a dialog to enter command options, a dialog to display
+some repository information and an abstract base class. The individual
+interfaces have to be subclasses of this base class.
+"""
+
+from E5Gui.E5Application import e5App
+
+######################################################################
+## Below is the factory function to instantiate the appropriate
+## vcs object depending on the project settings.
+######################################################################
+
+
+def factory(vcs):
+    """
+    Modul factory function to generate the right vcs object.
+    
+    @param vcs name of the VCS system to be used (string)
+    @return the instantiated VCS object
+    """
+    pluginManager = e5App().getObject("PluginManager")
+    if pluginManager is None:
+        # that should not happen
+        vc = None
+    
+    vc = pluginManager.getPluginObject("version_control", vcs,
+                                       maybeActive=True)
+    if vc is None:
+        # try alternative vcs interfaces assuming, that there is a common
+        # indicator for the alternatives
+        for vcsData in pluginManager.getVcsSystemIndicators().values():
+            for vcsSystem, _vcsSystemDisplay in vcsData:
+                if vcsSystem == vcs and len(vcsData) > 1:
+                    for vcsSystem, _vcsSystemDisplay in vcsData:
+                        if vcsSystem != vcs:
+                            vc = pluginManager.getPluginObject(
+                                "version_control", vcsSystem, maybeActive=True)
+                            if vc is not None:
+                                return vc
+    
+    return vc
+
+
+VcsBasicHelperSingleton = None
+
+
+def getBasicHelper(project):
+    """
+    Module function to get a reference to the basic project helper singleton.
+    
+    @param project reference to the project object (Project)
+    @return reference to the basic VCS project helper singleton
+        (VcsProjectHelper)
+    """
+    global VcsBasicHelperSingleton
+    
+    if VcsBasicHelperSingleton is None:
+        from .ProjectHelper import VcsProjectHelper
+        VcsBasicHelperSingleton = VcsProjectHelper(None, project)
+    
+    return VcsBasicHelperSingleton

eric ide

mercurial