src/eric7/Plugins/PluginVcsSubversion.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
31 pluginType = "version_control" 31 pluginType = "version_control"
32 pluginTypename = "Subversion" 32 pluginTypename = "Subversion"
33 className = "VcsSubversionPlugin" 33 className = "VcsSubversionPlugin"
34 packageName = "__core__" 34 packageName = "__core__"
35 shortDescription = "Implements the Subversion version control interface." 35 shortDescription = "Implements the Subversion version control interface."
36 longDescription = ( 36 longDescription = """This plugin provides the Subversion version control interface."""
37 """This plugin provides the Subversion version control interface."""
38 )
39 pyqtApi = 2 37 pyqtApi = 2
40 # End-Of-Header 38 # End-Of-Header
41 39
42 error = "" 40 error = ""
43 41
44 42
45 def exeDisplayData(): 43 def exeDisplayData():
46 """ 44 """
47 Public method to support the display of some executable info. 45 Public method to support the display of some executable info.
48 46
49 @return dictionary containing the data to query the presence of 47 @return dictionary containing the data to query the presence of
50 the executable 48 the executable
51 """ 49 """
52 exe = 'svn' 50 exe = "svn"
53 if Utilities.isWindowsPlatform(): 51 if Utilities.isWindowsPlatform():
54 exe += '.exe' 52 exe += ".exe"
55 53
56 data = { 54 data = {
57 "programEntry": True, 55 "programEntry": True,
58 "header": QCoreApplication.translate( 56 "header": QCoreApplication.translate(
59 "VcsSubversionPlugin", "Version Control - Subversion (svn)"), 57 "VcsSubversionPlugin", "Version Control - Subversion (svn)"
58 ),
60 "exe": exe, 59 "exe": exe,
61 "versionCommand": '--version', 60 "versionCommand": "--version",
62 "versionStartsWith": 'svn', 61 "versionStartsWith": "svn",
63 "versionPosition": 2, 62 "versionPosition": 2,
64 "version": "", 63 "version": "",
65 "versionCleanup": None, 64 "versionCleanup": None,
66 } 65 }
67 66
68 return data 67 return data
69 68
70 69
71 def getVcsSystemIndicator(): 70 def getVcsSystemIndicator():
72 """ 71 """
73 Public function to get the indicators for this version control system. 72 Public function to get the indicators for this version control system.
74 73
75 @return dictionary with indicator as key and a tuple with the vcs name 74 @return dictionary with indicator as key and a tuple with the vcs name
76 (string) and vcs display string (string) 75 (string) and vcs display string (string)
77 """ 76 """
78 global pluginTypename 77 global pluginTypename
79 data = {} 78 data = {}
80 exe = 'svn' 79 exe = "svn"
81 if Utilities.isWindowsPlatform(): 80 if Utilities.isWindowsPlatform():
82 exe += '.exe' 81 exe += ".exe"
83 if Utilities.isinpath(exe): 82 if Utilities.isinpath(exe):
84 data[".svn"] = (pluginTypename, displayString()) 83 data[".svn"] = (pluginTypename, displayString())
85 data["_svn"] = (pluginTypename, displayString()) 84 data["_svn"] = (pluginTypename, displayString())
86 return data 85 return data
87 86
88 87
89 def displayString(): 88 def displayString():
90 """ 89 """
91 Public function to get the display string. 90 Public function to get the display string.
92 91
93 @return display string (string) 92 @return display string (string)
94 """ 93 """
95 exe = 'svn' 94 exe = "svn"
96 if Utilities.isWindowsPlatform(): 95 if Utilities.isWindowsPlatform():
97 exe += '.exe' 96 exe += ".exe"
98 if Utilities.isinpath(exe): 97 if Utilities.isinpath(exe):
99 return QCoreApplication.translate( 98 return QCoreApplication.translate("VcsSubversionPlugin", "Subversion (svn)")
100 'VcsSubversionPlugin', 'Subversion (svn)')
101 else: 99 else:
102 return "" 100 return ""
103 101
102
104 subversionCfgPluginObject = None 103 subversionCfgPluginObject = None
105 104
106 105
107 def createConfigurationPage(configDlg): 106 def createConfigurationPage(configDlg):
108 """ 107 """
109 Module function to create the configuration page. 108 Module function to create the configuration page.
110 109
111 @param configDlg reference to the configuration dialog (QDialog) 110 @param configDlg reference to the configuration dialog (QDialog)
112 @return reference to the configuration page 111 @return reference to the configuration page
113 """ 112 """
114 global subversionCfgPluginObject 113 global subversionCfgPluginObject
115 from VcsPlugins.vcsSubversion.ConfigurationPage.SubversionPage import ( 114 from VcsPlugins.vcsSubversion.ConfigurationPage.SubversionPage import SubversionPage
116 SubversionPage 115
117 )
118 if subversionCfgPluginObject is None: 116 if subversionCfgPluginObject is None:
119 subversionCfgPluginObject = VcsSubversionPlugin(None) 117 subversionCfgPluginObject = VcsSubversionPlugin(None)
120 page = SubversionPage(subversionCfgPluginObject) 118 page = SubversionPage(subversionCfgPluginObject)
121 return page 119 return page
122 120
123 121
124 def getConfigData(): 122 def getConfigData():
125 """ 123 """
126 Module function returning data as required by the configuration dialog. 124 Module function returning data as required by the configuration dialog.
127 125
128 @return dictionary with key "zzz_subversionPage" containing the relevant 126 @return dictionary with key "zzz_subversionPage" containing the relevant
129 data 127 data
130 """ 128 """
131 return { 129 return {
132 "zzz_subversionPage": 130 "zzz_subversionPage": [
133 [QCoreApplication.translate("VcsSubversionPlugin", "Subversion"), 131 QCoreApplication.translate("VcsSubversionPlugin", "Subversion"),
134 os.path.join("VcsPlugins", "vcsSubversion", "icons", 132 os.path.join(
135 "preferences-subversion.svg"), 133 "VcsPlugins", "vcsSubversion", "icons", "preferences-subversion.svg"
136 createConfigurationPage, "vcsPage", None], 134 ),
135 createConfigurationPage,
136 "vcsPage",
137 None,
138 ],
137 } 139 }
138 140
139 141
140 def prepareUninstall(): 142 def prepareUninstall():
141 """ 143 """
142 Module function to prepare for an uninstallation. 144 Module function to prepare for an uninstallation.
143 """ 145 """
144 if not ericApp().getObject("PluginManager").isPluginLoaded( 146 if not ericApp().getObject("PluginManager").isPluginLoaded("PluginVcsSubversion"):
145 "PluginVcsSubversion"):
146 Preferences.getSettings().remove("Subversion") 147 Preferences.getSettings().remove("Subversion")
147 148
148 149
149 class VcsSubversionPlugin(QObject): 150 class VcsSubversionPlugin(QObject):
150 """ 151 """
151 Class implementing the Subversion version control plugin. 152 Class implementing the Subversion version control plugin.
152 """ 153 """
154
153 def __init__(self, ui): 155 def __init__(self, ui):
154 """ 156 """
155 Constructor 157 Constructor
156 158
157 @param ui reference to the user interface object (UI.UserInterface) 159 @param ui reference to the user interface object (UI.UserInterface)
158 """ 160 """
159 super().__init__(ui) 161 super().__init__(ui)
160 self.__ui = ui 162 self.__ui = ui
161 163
162 self.__subversionDefaults = { 164 self.__subversionDefaults = {
163 "StopLogOnCopy": True, 165 "StopLogOnCopy": True,
164 "LogLimit": 20, 166 "LogLimit": 20,
165 } 167 }
166 168
167 from VcsPlugins.vcsSubversion.ProjectHelper import SvnProjectHelper 169 from VcsPlugins.vcsSubversion.ProjectHelper import SvnProjectHelper
170
168 self.__projectHelperObject = SvnProjectHelper(None, None) 171 self.__projectHelperObject = SvnProjectHelper(None, None)
169 with contextlib.suppress(KeyError): 172 with contextlib.suppress(KeyError):
170 ericApp().registerPluginObject( 173 ericApp().registerPluginObject(
171 pluginTypename, self.__projectHelperObject, pluginType) 174 pluginTypename, self.__projectHelperObject, pluginType
175 )
172 readShortcuts(pluginName=pluginTypename) 176 readShortcuts(pluginName=pluginTypename)
173 177
174 def getProjectHelper(self): 178 def getProjectHelper(self):
175 """ 179 """
176 Public method to get a reference to the project helper object. 180 Public method to get a reference to the project helper object.
177 181
178 @return reference to the project helper object 182 @return reference to the project helper object
179 """ 183 """
180 return self.__projectHelperObject 184 return self.__projectHelperObject
181 185
182 def initToolbar(self, ui, toolbarManager): 186 def initToolbar(self, ui, toolbarManager):
183 """ 187 """
184 Public slot to initialize the VCS toolbar. 188 Public slot to initialize the VCS toolbar.
185 189
186 @param ui reference to the main window (UserInterface) 190 @param ui reference to the main window (UserInterface)
187 @param toolbarManager reference to a toolbar manager object 191 @param toolbarManager reference to a toolbar manager object
188 (EricToolBarManager) 192 (EricToolBarManager)
189 """ 193 """
190 if self.__projectHelperObject: 194 if self.__projectHelperObject:
191 self.__projectHelperObject.initToolbar(ui, toolbarManager) 195 self.__projectHelperObject.initToolbar(ui, toolbarManager)
192 196
193 def activate(self): 197 def activate(self):
194 """ 198 """
195 Public method to activate this plugin. 199 Public method to activate this plugin.
196 200
197 @return tuple of reference to instantiated viewmanager and 201 @return tuple of reference to instantiated viewmanager and
198 activation status (boolean) 202 activation status (boolean)
199 """ 203 """
200 from VcsPlugins.vcsSubversion.subversion import Subversion 204 from VcsPlugins.vcsSubversion.subversion import Subversion
205
201 self.__object = Subversion(self, self.__ui) 206 self.__object = Subversion(self, self.__ui)
202 207
203 tb = self.__ui.getToolbar("vcs")[1] 208 tb = self.__ui.getToolbar("vcs")[1]
204 tb.setVisible(False) 209 tb.setVisible(False)
205 tb.setEnabled(False) 210 tb.setEnabled(False)
206 211
207 tb = self.__ui.getToolbar("subversion")[1] 212 tb = self.__ui.getToolbar("subversion")[1]
208 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) 213 tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
209 tb.setEnabled(True) 214 tb.setEnabled(True)
210 215
211 return self.__object, True 216 return self.__object, True
212 217
213 def deactivate(self): 218 def deactivate(self):
214 """ 219 """
215 Public method to deactivate this plugin. 220 Public method to deactivate this plugin.
216 """ 221 """
217 self.__object = None 222 self.__object = None
218 223
219 tb = self.__ui.getToolbar("subversion")[1] 224 tb = self.__ui.getToolbar("subversion")[1]
220 tb.setVisible(False) 225 tb.setVisible(False)
221 tb.setEnabled(False) 226 tb.setEnabled(False)
222 227
223 tb = self.__ui.getToolbar("vcs")[1] 228 tb = self.__ui.getToolbar("vcs")[1]
224 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) 229 tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
225 tb.setEnabled(True) 230 tb.setEnabled(True)
226 231
227 def getPreferences(self, key): 232 def getPreferences(self, key):
228 """ 233 """
229 Public method to retrieve the various settings. 234 Public method to retrieve the various settings.
230 235
231 @param key the key of the value to get 236 @param key the key of the value to get
232 @return the requested setting 237 @return the requested setting
233 """ 238 """
234 if key in ["StopLogOnCopy"]: 239 if key in ["StopLogOnCopy"]:
235 return Preferences.toBool(Preferences.getSettings().value( 240 return Preferences.toBool(
236 "Subversion/" + key, self.__subversionDefaults[key])) 241 Preferences.getSettings().value(
242 "Subversion/" + key, self.__subversionDefaults[key]
243 )
244 )
237 elif key in ["LogLimit"]: 245 elif key in ["LogLimit"]:
238 return int(Preferences.getSettings().value( 246 return int(
239 "Subversion/" + key, 247 Preferences.getSettings().value(
240 self.__subversionDefaults[key])) 248 "Subversion/" + key, self.__subversionDefaults[key]
249 )
250 )
241 elif key in ["Commits"]: 251 elif key in ["Commits"]:
242 return Preferences.toList(Preferences.getSettings().value( 252 return Preferences.toList(
243 "Subversion/" + key)) 253 Preferences.getSettings().value("Subversion/" + key)
254 )
244 else: 255 else:
245 return Preferences.getSettings().value("Subversion/" + key) 256 return Preferences.getSettings().value("Subversion/" + key)
246 257
247 def setPreferences(self, key, value): 258 def setPreferences(self, key, value):
248 """ 259 """
249 Public method to store the various settings. 260 Public method to store the various settings.
250 261
251 @param key the key of the setting to be set 262 @param key the key of the setting to be set
252 @param value the value to be set 263 @param value the value to be set
253 """ 264 """
254 Preferences.getSettings().setValue("Subversion/" + key, value) 265 Preferences.getSettings().setValue("Subversion/" + key, value)
255 266
256 def getServersPath(self): 267 def getServersPath(self):
257 """ 268 """
258 Public method to get the filename of the servers file. 269 Public method to get the filename of the servers file.
259 270
260 @return filename of the servers file (string) 271 @return filename of the servers file (string)
261 """ 272 """
262 return getServersPath() 273 return getServersPath()
263 274
264 def getConfigPath(self): 275 def getConfigPath(self):
265 """ 276 """
266 Public method to get the filename of the config file. 277 Public method to get the filename of the config file.
267 278
268 @return filename of the config file (string) 279 @return filename of the config file (string)
269 """ 280 """
270 return getConfigPath() 281 return getConfigPath()
271 282
272 def prepareUninstall(self): 283 def prepareUninstall(self):
273 """ 284 """
274 Public method to prepare for an uninstallation. 285 Public method to prepare for an uninstallation.
275 """ 286 """
276 ericApp().unregisterPluginObject(pluginTypename) 287 ericApp().unregisterPluginObject(pluginTypename)
277 288
278 def prepareUnload(self): 289 def prepareUnload(self):
279 """ 290 """
280 Public method to prepare for an unload. 291 Public method to prepare for an unload.
281 """ 292 """
282 if self.__projectHelperObject: 293 if self.__projectHelperObject:
283 self.__projectHelperObject.removeToolbar( 294 self.__projectHelperObject.removeToolbar(
284 self.__ui, ericApp().getObject("ToolbarManager")) 295 self.__ui, ericApp().getObject("ToolbarManager")
296 )
285 ericApp().unregisterPluginObject(pluginTypename) 297 ericApp().unregisterPluginObject(pluginTypename)

eric ide

mercurial