VCS/VersionControl.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1083
dc680a0ce221
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
2 2
3 # Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing an abstract base class to be subclassed by all specific 7 Module implementing an abstract base class to be subclassed by all specific
8 VCS interfaces. 8 VCS interfaces.
9 """ 9 """
10 10
11 import os 11 import os
12 12
16 16
17 from E5Gui import E5MessageBox 17 from E5Gui import E5MessageBox
18 18
19 import Preferences 19 import Preferences
20 20
21
21 class VersionControl(QObject): 22 class VersionControl(QObject):
22 """ 23 """
23 Class implementing an abstract base class to be subclassed by all specific 24 Class implementing an abstract base class to be subclassed by all specific
24 VCS interfaces. 25 VCS interfaces.
25 26
26 It defines the vcs interface to be implemented by subclasses 27 It defines the vcs interface to be implemented by subclasses
27 and the common methods. 28 and the common methods.
28 29
34 vcsStatusMonitorStatus = pyqtSignal(str, str) 35 vcsStatusMonitorStatus = pyqtSignal(str, str)
35 36
36 canBeCommitted = 1 # Indicates that a file/directory is in the vcs. 37 canBeCommitted = 1 # Indicates that a file/directory is in the vcs.
37 canBeAdded = 2 # Indicates that a file/directory is not in vcs. 38 canBeAdded = 2 # Indicates that a file/directory is not in vcs.
38 39
39 def __init__(self, parent = None, name = None): 40 def __init__(self, parent=None, name=None):
40 """ 41 """
41 Constructor 42 Constructor
42 43
43 @param parent parent widget (QWidget) 44 @param parent parent widget (QWidget)
44 @param name name of this object (string) 45 @param name name of this object (string)
45 """ 46 """
46 QObject.__init__(self, parent) 47 QObject.__init__(self, parent)
47 if name: 48 if name:
48 self.setObjectName(name) 49 self.setObjectName(name)
49 self.defaultOptions = { 50 self.defaultOptions = {
50 'global' : [''], 51 'global': [''],
51 'commit' : [''], 52 'commit': [''],
52 'checkout' : [''], 53 'checkout': [''],
53 'update' : [''], 54 'update': [''],
54 'add' : [''], 55 'add': [''],
55 'remove' : [''], 56 'remove': [''],
56 'diff' : [''], 57 'diff': [''],
57 'log' : [''], 58 'log': [''],
58 'history' : [''], 59 'history': [''],
59 'status' : [''], 60 'status': [''],
60 'tag' : [''], 61 'tag': [''],
61 'export' : [''] 62 'export': ['']
62 } 63 }
63 self.interestingDataKeys = [] 64 self.interestingDataKeys = []
64 self.options = {} 65 self.options = {}
65 self.otherData = {} 66 self.otherData = {}
66 self.canDetectBinaries = True 67 self.canDetectBinaries = True
84 85
85 @exception RuntimeError not implemented 86 @exception RuntimeError not implemented
86 """ 87 """
87 raise RuntimeError('Not implemented') 88 raise RuntimeError('Not implemented')
88 89
89 def vcsInit(self, vcsDir, noDialog = False): 90 def vcsInit(self, vcsDir, noDialog=False):
90 """ 91 """
91 Public method used to initialize the vcs. 92 Public method used to initialize the vcs.
92 93
93 It must return a boolean to indicate an execution without errors. 94 It must return a boolean to indicate an execution without errors.
94 95
106 @param project reference to the project object 107 @param project reference to the project object
107 @exception RuntimeError not implemented 108 @exception RuntimeError not implemented
108 """ 109 """
109 raise RuntimeError('Not implemented') 110 raise RuntimeError('Not implemented')
110 111
111 def vcsImport(self, vcsDataDict, projectDir, noDialog = False): 112 def vcsImport(self, vcsDataDict, projectDir, noDialog=False):
112 """ 113 """
113 Public method used to import the project into the vcs. 114 Public method used to import the project into the vcs.
114 115
115 @param vcsDataDict dictionary of data required for the import 116 @param vcsDataDict dictionary of data required for the import
116 @param projectDir project directory (string) 117 @param projectDir project directory (string)
119 and a flag indicating the version controll status (boolean) 120 and a flag indicating the version controll status (boolean)
120 @exception RuntimeError not implemented 121 @exception RuntimeError not implemented
121 """ 122 """
122 raise RuntimeError('Not implemented') 123 raise RuntimeError('Not implemented')
123 124
124 def vcsCheckout(self, vcsDataDict, projectDir, noDialog = False): 125 def vcsCheckout(self, vcsDataDict, projectDir, noDialog=False):
125 """ 126 """
126 Public method used to check the project out of the vcs. 127 Public method used to check the project out of the vcs.
127 128
128 @param vcsDataDict dictionary of data required for the checkout 129 @param vcsDataDict dictionary of data required for the checkout
129 @param projectDir project directory to create (string) 130 @param projectDir project directory to create (string)
144 @return flag indicating an execution without errors (boolean) 145 @return flag indicating an execution without errors (boolean)
145 @exception RuntimeError not implemented 146 @exception RuntimeError not implemented
146 """ 147 """
147 raise RuntimeError('Not implemented') 148 raise RuntimeError('Not implemented')
148 149
149 def vcsCommit(self, name, message, noDialog = False): 150 def vcsCommit(self, name, message, noDialog=False):
150 """ 151 """
151 Public method used to make the change of a file/directory permanent in the vcs. 152 Public method used to make the change of a file/directory permanent in the vcs.
152 153
153 It must return a boolean to indicate an execution without errors. 154 It must return a boolean to indicate an execution without errors.
154 155
157 @param noDialog flag indicating quiet operations 158 @param noDialog flag indicating quiet operations
158 @exception RuntimeError not implemented 159 @exception RuntimeError not implemented
159 """ 160 """
160 raise RuntimeError('Not implemented') 161 raise RuntimeError('Not implemented')
161 162
162 def vcsUpdate(self, name, noDialog = False): 163 def vcsUpdate(self, name, noDialog=False):
163 """ 164 """
164 Public method used to update a file/directory in the vcs. 165 Public method used to update a file/directory in the vcs.
165 166
166 It must not return anything. 167 It must not return anything.
167 168
171 or delete (boolean) 172 or delete (boolean)
172 @exception RuntimeError not implemented 173 @exception RuntimeError not implemented
173 """ 174 """
174 raise RuntimeError('Not implemented') 175 raise RuntimeError('Not implemented')
175 176
176 def vcsAdd(self, name, isDir = False, noDialog = False): 177 def vcsAdd(self, name, isDir=False, noDialog=False):
177 """ 178 """
178 Public method used to add a file/directory in the vcs. 179 Public method used to add a file/directory in the vcs.
179 180
180 It must not return anything. 181 It must not return anything.
181 182
184 @param noDialog flag indicating quiet operations (boolean) 185 @param noDialog flag indicating quiet operations (boolean)
185 @exception RuntimeError not implemented 186 @exception RuntimeError not implemented
186 """ 187 """
187 raise RuntimeError('Not implemented') 188 raise RuntimeError('Not implemented')
188 189
189 def vcsAddBinary(self, name, isDir = False): 190 def vcsAddBinary(self, name, isDir=False):
190 """ 191 """
191 Public method used to add a file/directory in binary mode in the vcs. 192 Public method used to add a file/directory in binary mode in the vcs.
192 193
193 It must not return anything. 194 It must not return anything.
194 195
207 @param path root directory of the tree to be added (string) 208 @param path root directory of the tree to be added (string)
208 @exception RuntimeError not implemented 209 @exception RuntimeError not implemented
209 """ 210 """
210 raise RuntimeError('Not implemented') 211 raise RuntimeError('Not implemented')
211 212
212 def vcsRemove(self, name, project = False, noDialog = False): 213 def vcsRemove(self, name, project=False, noDialog=False):
213 """ 214 """
214 Public method used to add a file/directory in the vcs. 215 Public method used to add a file/directory in the vcs.
215 216
216 It must return a flag indicating successfull operation 217 It must return a flag indicating successfull operation
217 218
220 @param noDialog flag indicating quiet operations 221 @param noDialog flag indicating quiet operations
221 @exception RuntimeError not implemented 222 @exception RuntimeError not implemented
222 """ 223 """
223 raise RuntimeError('Not implemented') 224 raise RuntimeError('Not implemented')
224 225
225 def vcsMove(self, name, project, target = None, noDialog = False): 226 def vcsMove(self, name, project, target=None, noDialog=False):
226 """ 227 """
227 Public method used to move a file/directory. 228 Public method used to move a file/directory.
228 229
229 @param name file/directory name to be moved (string) 230 @param name file/directory name to be moved (string)
230 @param project reference to the project object 231 @param project reference to the project object
338 """ 339 """
339 Public method used to get the registered states of a number of files in the vcs. 340 Public method used to get the registered states of a number of files in the vcs.
340 341
341 @param names dictionary with all filenames to be checked as keys 342 @param names dictionary with all filenames to be checked as keys
342 @param dname directory to check in (string) 343 @param dname directory to check in (string)
343 @return the received dictionary completed with a combination of 344 @return the received dictionary completed with a combination of
344 canBeCommited and canBeAdded or None in order to signal an error 345 canBeCommited and canBeAdded or None in order to signal an error
345 @exception RuntimeError not implemented 346 @exception RuntimeError not implemented
346 """ 347 """
347 raise RuntimeError('Not implemented') 348 raise RuntimeError('Not implemented')
348 349
371 @param name directory name of the working directory (string) 372 @param name directory name of the working directory (string)
372 @exception RuntimeError not implemented 373 @exception RuntimeError not implemented
373 """ 374 """
374 raise RuntimeError('Not implemented') 375 raise RuntimeError('Not implemented')
375 376
376 def vcsOptionsDialog(self, project, archive, editable = False, parent = None): 377 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
377 """ 378 """
378 Public method to get a dialog to enter repository info. 379 Public method to get a dialog to enter repository info.
379 380
380 @param project reference to the project object 381 @param project reference to the project object
381 @param archive name of the project in the repository (string) 382 @param archive name of the project in the repository (string)
382 @param editable flag indicating that the project name is editable (boolean) 383 @param editable flag indicating that the project name is editable (boolean)
383 @param parent parent widget (QWidget) 384 @param parent parent widget (QWidget)
384 """ 385 """
385 raise RuntimeError('Not implemented') 386 raise RuntimeError('Not implemented')
386 387
387 def vcsNewProjectOptionsDialog(self, parent = None): 388 def vcsNewProjectOptionsDialog(self, parent=None):
388 """ 389 """
389 Public method to get a dialog to enter repository info for getting a new project. 390 Public method to get a dialog to enter repository info for getting a new project.
390 391
391 @param parent parent widget (QWidget) 392 @param parent parent widget (QWidget)
392 """ 393 """
399 @param ppath local path to get the repository infos (string) 400 @param ppath local path to get the repository infos (string)
400 @return string with ready formated info for display (string) 401 @return string with ready formated info for display (string)
401 """ 402 """
402 raise RuntimeError('Not implemented') 403 raise RuntimeError('Not implemented')
403 404
404 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser = False): 405 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser=False):
405 """ 406 """
406 Public method to instanciate a helper object for the different project browsers. 407 Public method to instanciate a helper object for the different project browsers.
407 408
408 @param browser reference to the project browser object 409 @param browser reference to the project browser object
409 @param project reference to the project object 410 @param project reference to the project object
507 508
508 ##################################################################### 509 #####################################################################
509 ## below are some utility methods 510 ## below are some utility methods
510 ##################################################################### 511 #####################################################################
511 512
512 def startSynchronizedProcess(self, proc, program, arguments, workingDir = None): 513 def startSynchronizedProcess(self, proc, program, arguments, workingDir=None):
513 """ 514 """
514 Public method to start a synchroneous process 515 Public method to start a synchroneous process
515 516
516 This method starts a process and waits 517 This method starts a process and waits
517 for its end while still serving the Qt event loop. 518 for its end while still serving the Qt event loop.
558 dn, fn = os.path.split(name) 559 dn, fn = os.path.split(name)
559 return (dn, fn) 560 return (dn, fn)
560 561
561 def splitPathList(self, names): 562 def splitPathList(self, names):
562 """ 563 """
563 Public method splitting the list of names into a common directory part and 564 Public method splitting the list of names into a common directory part and
564 a file list. 565 a file list.
565 566
566 @param names list of paths (list of strings) 567 @param names list of paths (list of strings)
567 @return a tuple of string and list of strings (dirname, filenamelist) 568 @return a tuple of string and list of strings (dirname, filenamelist)
568 """ 569 """
654 self.statusMonitorThread.wait(10000) 655 self.statusMonitorThread.wait(10000)
655 if not self.statusMonitorThread.isFinished(): 656 if not self.statusMonitorThread.isFinished():
656 self.statusMonitorThread.terminate() 657 self.statusMonitorThread.terminate()
657 self.statusMonitorThread.wait(10000) 658 self.statusMonitorThread.wait(10000)
658 self.statusMonitorThread = None 659 self.statusMonitorThread = None
659 self.__statusMonitorStatus("off", 660 self.__statusMonitorStatus("off",
660 self.trUtf8("Repository status checking is switched off")) 661 self.trUtf8("Repository status checking is switched off"))
661 662
662 def setStatusMonitorInterval(self, interval, project): 663 def setStatusMonitorInterval(self, interval, project):
663 """ 664 """
664 Public method to change the monitor interval. 665 Public method to change the monitor interval.

eric ide

mercurial