eric6/VCS/__init__.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
permissions
-rw-r--r--

Updated copyright for 2021.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3013
fe886b7f8f40 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
7 Module implementing the general part of the interface to version control
fe886b7f8f40 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
8 systems.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 The general part of the VCS interface defines classes to implement common
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 dialogs. These are a dialog to enter command options, a dialog to display
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
12 some repository information and an abstract base class. The individual
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
13 interfaces have to be subclasses of this base class.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
16 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 ######################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 ## Below is the factory function to instantiate the appropriate
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 ## vcs object depending on the project settings.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 ######################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def factory(vcs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Modul factory function to generate the right vcs object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param vcs name of the VCS system to be used (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @return the instantiated VCS object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
31 pluginManager = e5App().getObject("PluginManager")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 if pluginManager is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 # that should not happen
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 vc = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
3013
fe886b7f8f40 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
36 vc = pluginManager.getPluginObject("version_control", vcs,
fe886b7f8f40 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
37 maybeActive=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 if vc is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 # try alternative vcs interfaces assuming, that there is a common
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 # indicator for the alternatives
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 for vcsData in pluginManager.getVcsSystemIndicators().values():
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 for vcsSystem, _vcsSystemDisplay in vcsData:
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
43 if vcsSystem == vcs and len(vcsData) > 1:
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 for vcsSystem, _vcsSystemDisplay in vcsData:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 if vcsSystem != vcs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 vc = pluginManager.getPluginObject(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
47 "version_control", vcsSystem, maybeActive=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 if vc is not None:
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
49 return vc
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
50
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
51 return vc
4079
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
52
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
53
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
54 VcsBasicHelperSingleton = None
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
55
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
56
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
57 def getBasicHelper(project):
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
58 """
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
59 Module function to get a reference to the basic project helper singleton.
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
60
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
61 @param project reference to the project object (Project)
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
62 @return reference to the basic VCS project helper singleton
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
63 (VcsProjectHelper)
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
64 """
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
65 global VcsBasicHelperSingleton
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
66
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
67 if VcsBasicHelperSingleton is None:
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
68 from .ProjectHelper import VcsProjectHelper
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
69 VcsBasicHelperSingleton = VcsProjectHelper(None, project)
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
70
a3319822d303 Added possibility for plug-ins to have toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
71 return VcsBasicHelperSingleton

eric ide

mercurial