Plugins/PluginVcsSubversion.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Subversion version control plugin.
8 """
9
10 import os
11 import sys
12
13 from PyQt4.QtCore import QVariant
14 from PyQt4.QtGui import QApplication
15
16 from E4Gui.E4Application import e4App
17
18 import Preferences
19 from Preferences.Shortcuts import readShortcuts
20
21 from VcsPlugins.vcsSubversion.SvnUtilities import getConfigPath, getServersPath
22
23 import Utilities
24
25 # Start-Of-Header
26 name = "Subversion Plugin"
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
28 autoactivate = False
29 deactivateable = True
30 version = "5.0.0"
31 pluginType = "version_control"
32 pluginTypename = "Subversion"
33 className = "VcsSubversionPlugin"
34 packageName = "__core__"
35 shortDescription = "Implements the Subversion version control interface."
36 longDescription = """This plugin provides the Subversion version control interface."""
37 pyqtApi = 2
38 # End-Of-Header
39
40 error = ""
41
42 def exeDisplayData():
43 """
44 Public method to support the display of some executable info.
45
46 @return dictionary containing the data to query the presence of
47 the executable
48 """
49 exe = 'svn'
50 if Utilities.isWindowsPlatform():
51 exe += '.exe'
52
53 data = {
54 "programEntry" : True,
55 "header" : QApplication.translate("VcsSubversionPlugin",
56 "Version Control - Subversion (svn)"),
57 "exe" : exe,
58 "versionCommand" : '--version',
59 "versionStartsWith" : 'svn',
60 "versionPosition" : 2,
61 "version" : "",
62 "versionCleanup" : None,
63 }
64
65 return data
66
67 def getVcsSystemIndicator():
68 """
69 Public function to get the indicators for this version control system.
70
71 @return dictionary with indicator as key and a tuple with the vcs name (string)
72 and vcs display string (string)
73 """
74 global pluginTypename
75 data = {}
76 exe = 'svn'
77 if Utilities.isWindowsPlatform():
78 exe += '.exe'
79 if Utilities.isinpath(exe):
80 data[".svn"] = (pluginTypename, displayString())
81 data["_svn"] = (pluginTypename, displayString())
82 return data
83
84 def displayString():
85 """
86 Public function to get the display string.
87
88 @return display string (QString)
89 """
90 exe = 'svn'
91 if Utilities.isWindowsPlatform():
92 exe += '.exe'
93 if Utilities.isinpath(exe):
94 return QApplication.translate('VcsSubversionPlugin', 'Subversion (svn)')
95 else:
96 return ""
97
98 subversionCfgPluginObject = None
99
100 def createConfigurationPage(configDlg):
101 """
102 Module function to create the configuration page.
103
104 @return reference to the configuration page
105 """
106 global subversionCfgPluginObject
107 from VcsPlugins.vcsSubversion.ConfigurationPage.SubversionPage import SubversionPage
108 if subversionCfgPluginObject is None:
109 subversionCfgPluginObject = VcsSubversionPlugin(None)
110 page = SubversionPage(subversionCfgPluginObject)
111 return page
112
113 def getConfigData():
114 """
115 Module function returning data as required by the configuration dialog.
116
117 @return dictionary with key "zzz_subversionPage" containing the relevant data
118 """
119 return {
120 "zzz_subversionPage" : \
121 [QApplication.translate("VcsSubversionPlugin", "Subversion"),
122 os.path.join("VcsPlugins", "vcsSubversion", "icons",
123 "preferences-subversion.png"),
124 createConfigurationPage, "vcsPage", None],
125 }
126
127 def prepareUninstall():
128 """
129 Module function to prepare for an uninstallation.
130 """
131 if not e4App().getObject("PluginManager").isPluginLoaded("PluginVcsSubversion"):
132 Preferences.Prefs.settings.remove("Subversion")
133
134 class VcsSubversionPlugin(object):
135 """
136 Class implementing the Subversion version control plugin.
137 """
138 def __init__(self, ui):
139 """
140 Constructor
141
142 @param ui reference to the user interface object (UI.UserInterface)
143 """
144 self.__ui = ui
145
146 self.__subversionDefaults = {
147 "StopLogOnCopy" : 1,
148 "LogLimit" : 100,
149 "CommitMessages" : 20,
150 }
151
152 from VcsPlugins.vcsSubversion.ProjectHelper import SvnProjectHelper
153 self.__projectHelperObject = SvnProjectHelper(None, None)
154 try:
155 e4App().registerPluginObject(pluginTypename, self.__projectHelperObject,
156 pluginType)
157 except KeyError:
158 pass # ignore duplicate registration
159 readShortcuts(pluginName = pluginTypename)
160
161 def getProjectHelper(self):
162 """
163 Public method to get a reference to the project helper object.
164
165 @return reference to the project helper object
166 """
167 return self.__projectHelperObject
168
169 def activate(self):
170 """
171 Public method to activate this plugin.
172
173 @return tuple of reference to instantiated viewmanager and
174 activation status (boolean)
175 """
176 from VcsPlugins.vcsSubversion.subversion import Subversion
177 self.__object = Subversion(self, self.__ui)
178 return self.__object, True
179
180 def deactivate(self):
181 """
182 Public method to deactivate this plugin.
183 """
184 self.__object = None
185
186 def getPreferences(self, key):
187 """
188 Public method to retrieve the various refactoring settings.
189
190 @param key the key of the value to get
191 @param prefClass preferences class used as the storage area
192 @return the requested refactoring setting
193 """
194 if key in ["Commits"]:
195 return Preferences.Prefs.settings.value("Subversion/" + key).toStringList()
196 else:
197 return Preferences.Prefs.settings.value("Subversion/" + key,
198 QVariant(self.__subversionDefaults[key])).toInt()[0]
199
200 def setPreferences(self, key, value):
201 """
202 Public method to store the various refactoring settings.
203
204 @param key the key of the setting to be set
205 @param value the value to be set
206 @param prefClass preferences class used as the storage area
207 """
208 Preferences.Prefs.settings.setValue("Subversion/" + key, QVariant(value))
209
210 def getServersPath(self):
211 """
212 Public method to get the filename of the servers file.
213
214 @return filename of the servers file (string)
215 """
216 return getServersPath()
217
218 def getConfigPath(self):
219 """
220 Public method to get the filename of the config file.
221
222 @return filename of the config file (string)
223 """
224 return getConfigPath()
225
226 def prepareUninstall(self):
227 """
228 Public method to prepare for an uninstallation.
229 """
230 e4App().unregisterPluginObject(pluginTypename)

eric ide

mercurial