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

eric ide

mercurial