VCS/__init__.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the general part of the interface to version control systems.
8
9 The general part of the VCS interface defines classes to implement common
10 dialogs. These are a dialog to enter command options, a dialog to display
11 some repository information and an abstract base class. The individual
12 interfaces (i.e. CVS) have to be subclasses of this base class.
13 """
14
15 from E4Gui.E4Application import e4App
16
17 import Preferences
18
19 ######################################################################
20 ## Below is the factory function to instantiate the appropriate
21 ## vcs object depending on the project settings.
22 ######################################################################
23
24 def factory(vcs):
25 """
26 Modul factory function to generate the right vcs object.
27
28 @param vcs name of the VCS system to be used (string)
29 @return the instantiated VCS object
30 """
31 pluginManager = e4App().getObject("PluginManager")
32 if pluginManager is None:
33 # that should not happen
34 vc = None
35
36 vc = pluginManager.getPluginObject("version_control", vcs, maybeActive = True)
37 if vc is None:
38 # try alternative vcs interfaces assuming, that there is a common
39 # indicator for the alternatives
40 found = False
41 for indicator, vcsData in pluginManager.getVcsSystemIndicators().items():
42 for vcsSystem, vcsSystemDisplay in vcsData:
43 if vcsSystem == vcs:
44 found = True
45 break
46
47 if found:
48 if len(vcsData) > 1:
49 for vcsSystem, vcsSystemDisplay in vcsData:
50 if vcsSystem != vcs:
51 vc = pluginManager.getPluginObject(
52 "version_control", vcsSystem, maybeActive = True)
53 if vc is not None:
54 break
55 break
56 return vc

eric ide

mercurial