VCS/VersionControl.py

changeset 2965
d133c7edd88a
parent 2853
0866c3aac79f
child 3057
10516539f238
child 3160
209a07d7e401
equal deleted inserted replaced
2964:84b65fb9e780 2965:d133c7edd88a
26 26
27 It defines the vcs interface to be implemented by subclasses 27 It defines the vcs interface to be implemented by subclasses
28 and the common methods. 28 and the common methods.
29 29
30 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status 30 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status
31 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of the 31 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of
32 monitoring thread (ok, nok, op, off) and a status message 32 the monitoring thread (ok, nok, op, off) and a status message
33 @signal vcsStatusChanged() emitted to indicate a change of the overall VCS status 33 @signal vcsStatusChanged() emitted to indicate a change of the overall
34 VCS status
34 """ 35 """
35 vcsStatusMonitorData = pyqtSignal(list) 36 vcsStatusMonitorData = pyqtSignal(list)
36 vcsStatusMonitorStatus = pyqtSignal(str, str) 37 vcsStatusMonitorStatus = pyqtSignal(str, str)
37 vcsStatusChanged = pyqtSignal() 38 vcsStatusChanged = pyqtSignal()
38 39
73 self.vcsExecutionMutex = QMutex() 74 self.vcsExecutionMutex = QMutex()
74 75
75 def vcsShutdown(self): 76 def vcsShutdown(self):
76 """ 77 """
77 Public method used to shutdown the vcs interface. 78 Public method used to shutdown the vcs interface.
79
80 @exception RuntimeError to indicate that this method must be
81 implemented by a subclass
78 """ 82 """
79 raise RuntimeError('Not implemented') 83 raise RuntimeError('Not implemented')
80 84
81 def vcsExists(self): 85 def vcsExists(self):
82 """ 86 """
83 Public method used to test for the presence of the vcs. 87 Public method used to test for the presence of the vcs.
84 88
85 It must return a bool to indicate the existance and a string giving 89 @ireturn tuple of flag indicating the existence and a string
86 an error message in case of failure. 90 giving an error message in case of failure
87 91 @exception RuntimeError to indicate that this method must be
88 @exception RuntimeError not implemented 92 implemented by a subclass
89 """ 93 """
90 raise RuntimeError('Not implemented') 94 raise RuntimeError('Not implemented')
91 95
92 def vcsInit(self, vcsDir, noDialog=False): 96 def vcsInit(self, vcsDir, noDialog=False):
93 """ 97 """
94 Public method used to initialize the vcs. 98 Public method used to initialize the vcs.
95
96 It must return a boolean to indicate an execution without errors.
97 99
98 @param vcsDir name of the VCS directory (string) 100 @param vcsDir name of the VCS directory (string)
99 @param noDialog flag indicating quiet operations (boolean) 101 @param noDialog flag indicating quiet operations (boolean)
100 @exception RuntimeError not implemented 102 @ireturn flag indicating success (boolean)
103 @exception RuntimeError to indicate that this method must be
104 implemented by a subclass
101 """ 105 """
102 raise RuntimeError('Not implemented') 106 raise RuntimeError('Not implemented')
103 107
104 def vcsConvertProject(self, vcsDataDict, project): 108 def vcsConvertProject(self, vcsDataDict, project):
105 """ 109 """
106 Public method to convert an uncontrolled project to a version controlled project. 110 Public method to convert an uncontrolled project to a version
111 controlled project.
107 112
108 @param vcsDataDict dictionary of data required for the conversion 113 @param vcsDataDict dictionary of data required for the conversion
109 @param project reference to the project object 114 @param project reference to the project object
110 @exception RuntimeError not implemented 115 @exception RuntimeError to indicate that this method must be
116 implemented by a subclass
111 """ 117 """
112 raise RuntimeError('Not implemented') 118 raise RuntimeError('Not implemented')
113 119
114 def vcsImport(self, vcsDataDict, projectDir, noDialog=False): 120 def vcsImport(self, vcsDataDict, projectDir, noDialog=False):
115 """ 121 """
116 Public method used to import the project into the vcs. 122 Public method used to import the project into the vcs.
117 123
118 @param vcsDataDict dictionary of data required for the import 124 @param vcsDataDict dictionary of data required for the import
119 @param projectDir project directory (string) 125 @param projectDir project directory (string)
120 @param noDialog flag indicating quiet operations 126 @param noDialog flag indicating quiet operations
121 @return flag indicating an execution without errors (boolean) 127 @ireturn flag indicating an execution without errors (boolean)
122 and a flag indicating the version controll status (boolean) 128 and a flag indicating the version controll status (boolean)
123 @exception RuntimeError not implemented 129 @exception RuntimeError to indicate that this method must be
130 implemented by a subclass
124 """ 131 """
125 raise RuntimeError('Not implemented') 132 raise RuntimeError('Not implemented')
126 133
127 def vcsCheckout(self, vcsDataDict, projectDir, noDialog=False): 134 def vcsCheckout(self, vcsDataDict, projectDir, noDialog=False):
128 """ 135 """
129 Public method used to check the project out of the vcs. 136 Public method used to check the project out of the vcs.
130 137
131 @param vcsDataDict dictionary of data required for the checkout 138 @param vcsDataDict dictionary of data required for the checkout
132 @param projectDir project directory to create (string) 139 @param projectDir project directory to create (string)
133 @param noDialog flag indicating quiet operations 140 @param noDialog flag indicating quiet operations
134 @return flag indicating an execution without errors (boolean) 141 @ireturn flag indicating an execution without errors (boolean)
135 @exception RuntimeError not implemented 142 @exception RuntimeError to indicate that this method must be
143 implemented by a subclass
136 """ 144 """
137 raise RuntimeError('Not implemented') 145 raise RuntimeError('Not implemented')
138 146
139 def vcsExport(self, vcsDataDict, projectDir): 147 def vcsExport(self, vcsDataDict, projectDir):
140 """ 148 """
141 Public method used to export a directory from the vcs. 149 Public method used to export a directory from the vcs.
142
143 It must return a boolean to indicate an execution without errors.
144 150
145 @param vcsDataDict dictionary of data required for the export 151 @param vcsDataDict dictionary of data required for the export
146 @param projectDir project directory to create (string) 152 @param projectDir project directory to create (string)
147 @return flag indicating an execution without errors (boolean) 153 @ireturn flag indicating an execution without errors (boolean)
148 @exception RuntimeError not implemented 154 @exception RuntimeError to indicate that this method must be
155 implemented by a subclass
149 """ 156 """
150 raise RuntimeError('Not implemented') 157 raise RuntimeError('Not implemented')
151 158
152 def vcsCommit(self, name, message, noDialog=False): 159 def vcsCommit(self, name, message, noDialog=False):
153 """ 160 """
154 Public method used to make the change of a file/directory permanent in the vcs. 161 Public method used to make the change of a file/directory permanent in
155 162 the vcs.
156 It must return a boolean to indicate an execution without errors.
157 163
158 @param name file/directory name to be committed (string) 164 @param name file/directory name to be committed (string)
159 @param message message for this operation (string) 165 @param message message for this operation (string)
160 @param noDialog flag indicating quiet operations 166 @param noDialog flag indicating quiet operations (boolean)
161 @exception RuntimeError not implemented 167 @ireturn flag indicating success (boolean)
168 @exception RuntimeError to indicate that this method must be
169 implemented by a subclass
162 """ 170 """
163 raise RuntimeError('Not implemented') 171 raise RuntimeError('Not implemented')
164 172
165 def vcsUpdate(self, name, noDialog=False): 173 def vcsUpdate(self, name, noDialog=False):
166 """ 174 """
167 Public method used to update a file/directory in the vcs. 175 Public method used to update a file/directory in the vcs.
168
169 It must not return anything.
170 176
171 @param name file/directory name to be updated (string) 177 @param name file/directory name to be updated (string)
172 @param noDialog flag indicating quiet operations (boolean) 178 @param noDialog flag indicating quiet operations (boolean)
173 @return flag indicating, that the update contained an add 179 @ireturn flag indicating, that the update contained an add
174 or delete (boolean) 180 or delete (boolean)
175 @exception RuntimeError not implemented 181 @exception RuntimeError to indicate that this method must be
182 implemented by a subclass
176 """ 183 """
177 raise RuntimeError('Not implemented') 184 raise RuntimeError('Not implemented')
178 185
179 def vcsAdd(self, name, isDir=False, noDialog=False): 186 def vcsAdd(self, name, isDir=False, noDialog=False):
180 """ 187 """
181 Public method used to add a file/directory in the vcs. 188 Public method used to add a file/directory in the vcs.
182
183 It must not return anything.
184 189
185 @param name file/directory name to be added (string) 190 @param name file/directory name to be added (string)
186 @param isDir flag indicating name is a directory (boolean) 191 @param isDir flag indicating name is a directory (boolean)
187 @param noDialog flag indicating quiet operations (boolean) 192 @param noDialog flag indicating quiet operations (boolean)
188 @exception RuntimeError not implemented 193 @exception RuntimeError to indicate that this method must be
194 implemented by a subclass
189 """ 195 """
190 raise RuntimeError('Not implemented') 196 raise RuntimeError('Not implemented')
191 197
192 def vcsAddBinary(self, name, isDir=False): 198 def vcsAddBinary(self, name, isDir=False):
193 """ 199 """
194 Public method used to add a file/directory in binary mode in the vcs. 200 Public method used to add a file/directory in binary mode in the vcs.
195
196 It must not return anything.
197 201
198 @param name file/directory name to be added (string) 202 @param name file/directory name to be added (string)
199 @param isDir flag indicating name is a directory (boolean) 203 @param isDir flag indicating name is a directory (boolean)
200 @exception RuntimeError not implemented 204 @exception RuntimeError to indicate that this method must be
205 implemented by a subclass
201 """ 206 """
202 raise RuntimeError('Not implemented') 207 raise RuntimeError('Not implemented')
203 208
204 def vcsAddTree(self, path): 209 def vcsAddTree(self, path):
205 """ 210 """
206 Public method to add a directory tree rooted at path in the vcs. 211 Public method to add a directory tree rooted at path in the vcs.
207 212
208 It must not return anything.
209
210 @param path root directory of the tree to be added (string) 213 @param path root directory of the tree to be added (string)
211 @exception RuntimeError not implemented 214 @exception RuntimeError to indicate that this method must be
215 implemented by a subclass
212 """ 216 """
213 raise RuntimeError('Not implemented') 217 raise RuntimeError('Not implemented')
214 218
215 def vcsRemove(self, name, project=False, noDialog=False): 219 def vcsRemove(self, name, project=False, noDialog=False):
216 """ 220 """
217 Public method used to add a file/directory in the vcs. 221 Public method used to add a file/directory in the vcs.
218
219 It must return a flag indicating successfull operation
220 222
221 @param name file/directory name to be removed (string) 223 @param name file/directory name to be removed (string)
222 @param project flag indicating deletion of a project tree (boolean) 224 @param project flag indicating deletion of a project tree (boolean)
223 @param noDialog flag indicating quiet operations 225 @param noDialog flag indicating quiet operations
224 @exception RuntimeError not implemented 226 @ireturn flag indicating success (boolean)
227 @exception RuntimeError to indicate that this method must be
228 implemented by a subclass
225 """ 229 """
226 raise RuntimeError('Not implemented') 230 raise RuntimeError('Not implemented')
227 231
228 def vcsMove(self, name, project, target=None, noDialog=False): 232 def vcsMove(self, name, project, target=None, noDialog=False):
229 """ 233 """
231 235
232 @param name file/directory name to be moved (string) 236 @param name file/directory name to be moved (string)
233 @param project reference to the project object 237 @param project reference to the project object
234 @param target new name of the file/directory (string) 238 @param target new name of the file/directory (string)
235 @param noDialog flag indicating quiet operations 239 @param noDialog flag indicating quiet operations
236 @return flag indicating successfull operation (boolean) 240 @ireturn flag indicating successfull operation (boolean)
237 @exception RuntimeError not implemented 241 @exception RuntimeError to indicate that this method must be
242 implemented by a subclass
238 """ 243 """
239 raise RuntimeError('Not implemented') 244 raise RuntimeError('Not implemented')
240 245
241 def vcsLog(self, name): 246 def vcsLog(self, name):
242 """ 247 """
243 Public method used to view the log of a file/directory in the vcs. 248 Public method used to view the log of a file/directory in the vcs.
244 249
245 It must not return anything.
246
247 @param name file/directory name to show the log for (string) 250 @param name file/directory name to show the log for (string)
248 @exception RuntimeError not implemented 251 @exception RuntimeError to indicate that this method must be
252 implemented by a subclass
249 """ 253 """
250 raise RuntimeError('Not implemented') 254 raise RuntimeError('Not implemented')
251 255
252 def vcsDiff(self, name): 256 def vcsDiff(self, name):
253 """ 257 """
254 Public method used to view the diff of a file/directory in the vcs. 258 Public method used to view the diff of a file/directory in the vcs.
255 259
256 It must not return anything.
257
258 @param name file/directory name to be diffed (string) 260 @param name file/directory name to be diffed (string)
259 @exception RuntimeError not implemented 261 @exception RuntimeError to indicate that this method must be
262 implemented by a subclass
260 """ 263 """
261 raise RuntimeError('Not implemented') 264 raise RuntimeError('Not implemented')
262 265
263 def vcsHistory(self, name): 266 def vcsHistory(self, name):
264 """ 267 """
265 Public method used to view the history of a file/directory in the vcs. 268 Public method used to view the history of a file/directory in the vcs.
266 269
267 It must not return anything.
268
269 @param name file/directory name to show the history for (string) 270 @param name file/directory name to show the history for (string)
270 @exception RuntimeError not implemented 271 @exception RuntimeError to indicate that this method must be
272 implemented by a subclass
271 """ 273 """
272 raise RuntimeError('Not implemented') 274 raise RuntimeError('Not implemented')
273 275
274 def vcsStatus(self, name): 276 def vcsStatus(self, name):
275 """ 277 """
276 Public method used to view the status of a file/directory in the vcs. 278 Public method used to view the status of a file/directory in the vcs.
277 279
278 It must not return anything.
279
280 @param name file/directory name to show the status for (string) 280 @param name file/directory name to show the status for (string)
281 @exception RuntimeError not implemented 281 @exception RuntimeError to indicate that this method must be
282 implemented by a subclass
282 """ 283 """
283 raise RuntimeError('Not implemented') 284 raise RuntimeError('Not implemented')
284 285
285 def vcsTag(self, name): 286 def vcsTag(self, name):
286 """ 287 """
287 Public method used to set the tag of a file/directory in the vcs. 288 Public method used to set the tag of a file/directory in the vcs.
288 289
289 It must not return anything.
290
291 @param name file/directory name to be tagged (string) 290 @param name file/directory name to be tagged (string)
292 @exception RuntimeError not implemented 291 @exception RuntimeError to indicate that this method must be
292 implemented by a subclass
293 """ 293 """
294 raise RuntimeError('Not implemented') 294 raise RuntimeError('Not implemented')
295 295
296 def vcsRevert(self, name): 296 def vcsRevert(self, name):
297 """ 297 """
298 Public method used to revert changes made to a file/directory. 298 Public method used to revert changes made to a file/directory.
299 299
300 It must not return anything.
301
302 @param name file/directory name to be reverted (string) 300 @param name file/directory name to be reverted (string)
303 @exception RuntimeError not implemented 301 @exception RuntimeError to indicate that this method must be
302 implemented by a subclass
304 """ 303 """
305 raise RuntimeError('Not implemented') 304 raise RuntimeError('Not implemented')
306 305
307 def vcsSwitch(self, name): 306 def vcsSwitch(self, name):
308 """ 307 """
309 Public method used to switch a directory to a different tag/branch. 308 Public method used to switch a directory to a different tag/branch.
310 309
311 It must not return anything.
312
313 @param name directory name to be switched (string) 310 @param name directory name to be switched (string)
314 @return flag indicating, that the switch contained an add 311 @ireturn flag indicating, that the switch contained an add
315 or delete (boolean) 312 or delete (boolean)
316 @exception RuntimeError not implemented 313 @exception RuntimeError to indicate that this method must be
314 implemented by a subclass
317 """ 315 """
318 raise RuntimeError('Not implemented') 316 raise RuntimeError('Not implemented')
319 317
320 def vcsMerge(self, name): 318 def vcsMerge(self, name):
321 """ 319 """
322 Public method used to merge a tag/branch into the local project. 320 Public method used to merge a tag/branch into the local project.
323 321
324 It must not return anything.
325
326 @param name file/directory name to be merged (string) 322 @param name file/directory name to be merged (string)
327 @exception RuntimeError not implemented 323 @exception RuntimeError to indicate that this method must be
324 implemented by a subclass
328 """ 325 """
329 raise RuntimeError('Not implemented') 326 raise RuntimeError('Not implemented')
330 327
331 def vcsRegisteredState(self, name): 328 def vcsRegisteredState(self, name):
332 """ 329 """
333 Public method used to get the registered state of a file in the vcs. 330 Public method used to get the registered state of a file in the vcs.
334 331
335 @param name filename to check (string) 332 @param name filename to check (string)
336 @return a combination of canBeCommited and canBeAdded or 333 @ireturn a combination of canBeCommited and canBeAdded or
337 0 in order to signal an error 334 0 in order to signal an error
338 @exception RuntimeError not implemented 335 @exception RuntimeError to indicate that this method must be
336 implemented by a subclass
339 """ 337 """
340 raise RuntimeError('Not implemented') 338 raise RuntimeError('Not implemented')
341 339
342 def vcsAllRegisteredStates(self, names, dname): 340 def vcsAllRegisteredStates(self, names, dname):
343 """ 341 """
344 Public method used to get the registered states of a number of files in the vcs. 342 Public method used to get the registered states of a number of files
343 in the vcs.
345 344
346 @param names dictionary with all filenames to be checked as keys 345 @param names dictionary with all filenames to be checked as keys
347 @param dname directory to check in (string) 346 @param dname directory to check in (string)
348 @return the received dictionary completed with a combination of 347 @ireturn the received dictionary completed with a combination of
349 canBeCommited and canBeAdded or None in order to signal an error 348 canBeCommited and canBeAdded or None in order to signal an error
350 @exception RuntimeError not implemented 349 @exception RuntimeError to indicate that this method must be
350 implemented by a subclass
351 """ 351 """
352 raise RuntimeError('Not implemented') 352 raise RuntimeError('Not implemented')
353 353
354 def vcsName(self): 354 def vcsName(self):
355 """ 355 """
356 Public method returning the name of the vcs. 356 Public method returning the name of the vcs.
357 357
358 @return name of the vcs (string) 358 @ireturn name of the vcs (string)
359 @exception RuntimeError not implemented 359 @exception RuntimeError to indicate that this method must be
360 implemented by a subclass
360 """ 361 """
361 raise RuntimeError('Not implemented') 362 raise RuntimeError('Not implemented')
362 363
363 def vcsCleanup(self, name): 364 def vcsCleanup(self, name):
364 """ 365 """
365 Public method used to cleanup the local copy. 366 Public method used to cleanup the local copy.
366 367
367 @param name directory name to be cleaned up (string) 368 @param name directory name to be cleaned up (string)
368 @exception RuntimeError not implemented 369 @exception RuntimeError to indicate that this method must be
370 implemented by a subclass
369 """ 371 """
370 raise RuntimeError('Not implemented') 372 raise RuntimeError('Not implemented')
371 373
372 def vcsCommandLine(self, name): 374 def vcsCommandLine(self, name):
373 """ 375 """
374 Public method used to execute arbitrary vcs commands. 376 Public method used to execute arbitrary vcs commands.
375 377
376 @param name directory name of the working directory (string) 378 @param name directory name of the working directory (string)
377 @exception RuntimeError not implemented 379 @exception RuntimeError to indicate that this method must be
380 implemented by a subclass
378 """ 381 """
379 raise RuntimeError('Not implemented') 382 raise RuntimeError('Not implemented')
380 383
381 def vcsOptionsDialog(self, project, archive, editable=False, parent=None): 384 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
382 """ 385 """
383 Public method to get a dialog to enter repository info. 386 Public method to get a dialog to enter repository info.
384 387
385 @param project reference to the project object 388 @param project reference to the project object
386 @param archive name of the project in the repository (string) 389 @param archive name of the project in the repository (string)
387 @param editable flag indicating that the project name is editable (boolean) 390 @param editable flag indicating that the project name is editable
391 (boolean)
388 @param parent parent widget (QWidget) 392 @param parent parent widget (QWidget)
393 @exception RuntimeError to indicate that this method must be
394 implemented by a subclass
389 """ 395 """
390 raise RuntimeError('Not implemented') 396 raise RuntimeError('Not implemented')
391 397
392 def vcsNewProjectOptionsDialog(self, parent=None): 398 def vcsNewProjectOptionsDialog(self, parent=None):
393 """ 399 """
394 Public method to get a dialog to enter repository info for getting a new project. 400 Public method to get a dialog to enter repository info for getting a
401 new project.
395 402
396 @param parent parent widget (QWidget) 403 @param parent parent widget (QWidget)
404 @exception RuntimeError to indicate that this method must be
405 implemented by a subclass
397 """ 406 """
398 raise RuntimeError('Not implemented') 407 raise RuntimeError('Not implemented')
399 408
400 def vcsRepositoryInfos(self, ppath): 409 def vcsRepositoryInfos(self, ppath):
401 """ 410 """
402 Public method to retrieve information about the repository. 411 Public method to retrieve information about the repository.
403 412
404 @param ppath local path to get the repository infos (string) 413 @param ppath local path to get the repository infos (string)
405 @return string with ready formated info for display (string) 414 @ireturn string with ready formated info for display (string)
406 """ 415 @exception RuntimeError to indicate that this method must be
407 raise RuntimeError('Not implemented') 416 implemented by a subclass
408 417 """
409 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser=False): 418 raise RuntimeError('Not implemented')
410 """ 419
411 Public method to instanciate a helper object for the different project browsers. 420 def vcsGetProjectBrowserHelper(self, browser, project,
421 isTranslationsBrowser=False):
422 """
423 Public method to instanciate a helper object for the different
424 project browsers.
412 425
413 @param browser reference to the project browser object 426 @param browser reference to the project browser object
414 @param project reference to the project object 427 @param project reference to the project object
415 @param isTranslationsBrowser flag indicating, the helper is requested for the 428 @param isTranslationsBrowser flag indicating, the helper is requested
416 translations browser (this needs some special treatment) 429 for the translations browser (this needs some special treatment)
417 @return the project browser helper object 430 @ireturn the project browser helper object
431 @exception RuntimeError to indicate that this method must be
432 implemented by a subclass
418 """ 433 """
419 raise RuntimeError('Not implemented') 434 raise RuntimeError('Not implemented')
420 435
421 def vcsGetProjectHelper(self, project): 436 def vcsGetProjectHelper(self, project):
422 """ 437 """
423 Public method to instanciate a helper object for the project. 438 Public method to instanciate a helper object for the project.
424 439
425 @param project reference to the project object 440 @param project reference to the project object
426 @return the project helper object 441 @ireturn the project helper object
442 @exception RuntimeError to indicate that this method must be
443 implemented by a subclass
427 """ 444 """
428 raise RuntimeError('Not implemented') 445 raise RuntimeError('Not implemented')
429 446
430 ##################################################################### 447 #####################################################################
431 ## methods above need to be implemented by a subclass 448 ## methods above need to be implemented by a subclass
453 Public method used to retrieve the default options for the vcs. 470 Public method used to retrieve the default options for the vcs.
454 471
455 @return a dictionary with the vcs operations as key and 472 @return a dictionary with the vcs operations as key and
456 the respective options as values. The key 'global' must contain 473 the respective options as values. The key 'global' must contain
457 the global options. The other keys must be 'commit', 'update', 474 the global options. The other keys must be 'commit', 'update',
458 'add', 'remove', 'diff', 'log', 'history', 'tag', 'status' and 'export'. 475 'add', 'remove', 'diff', 'log', 'history', 'tag', 'status' and
476 'export'.
459 """ 477 """
460 return self.defaultOptions 478 return self.defaultOptions
461 479
462 def vcsSetOptions(self, options): 480 def vcsSetOptions(self, options):
463 """ 481 """
523 541
524 ##################################################################### 542 #####################################################################
525 ## below are some utility methods 543 ## below are some utility methods
526 ##################################################################### 544 #####################################################################
527 545
528 def startSynchronizedProcess(self, proc, program, arguments, workingDir=None): 546 def startSynchronizedProcess(self, proc, program, arguments,
529 """ 547 workingDir=None):
530 Public method to start a synchroneous process 548 """
549 Public method to start a synchroneous process.
531 550
532 This method starts a process and waits 551 This method starts a process and waits
533 for its end while still serving the Qt event loop. 552 for its end while still serving the Qt event loop.
534 553
535 @param proc process to start (QProcess) 554 @param proc process to start (QProcess)
544 if workingDir: 563 if workingDir:
545 proc.setWorkingDirectory(workingDir) 564 proc.setWorkingDirectory(workingDir)
546 proc.start(program, arguments) 565 proc.start(program, arguments)
547 procStarted = proc.waitForStarted(5000) 566 procStarted = proc.waitForStarted(5000)
548 if not procStarted: 567 if not procStarted:
549 E5MessageBox.critical(None, 568 E5MessageBox.critical(
569 None,
550 self.trUtf8('Process Generation Error'), 570 self.trUtf8('Process Generation Error'),
551 self.trUtf8( 571 self.trUtf8(
552 'The process {0} could not be started. ' 572 'The process {0} could not be started. '
553 'Ensure, that it is in the search path.' 573 'Ensure, that it is in the search path.'
554 ).format(program)) 574 ).format(program))
556 else: 576 else:
557 while proc.state() == QProcess.Running: 577 while proc.state() == QProcess.Running:
558 QApplication.processEvents() 578 QApplication.processEvents()
559 QThread.msleep(300) 579 QThread.msleep(300)
560 QApplication.processEvents() 580 QApplication.processEvents()
561 return (proc.exitStatus() == QProcess.NormalExit) and (proc.exitCode() == 0) 581 return (proc.exitStatus() == QProcess.NormalExit) and \
582 (proc.exitCode() == 0)
562 583
563 def splitPath(self, name): 584 def splitPath(self, name):
564 """ 585 """
565 Public method splitting name into a directory part and a file part. 586 Public method splitting name into a directory part and a file part.
566 587
574 dn, fn = os.path.split(name) 595 dn, fn = os.path.split(name)
575 return (dn, fn) 596 return (dn, fn)
576 597
577 def splitPathList(self, names): 598 def splitPathList(self, names):
578 """ 599 """
579 Public method splitting the list of names into a common directory part and 600 Public method splitting the list of names into a common directory part
580 a file list. 601 and a file list.
581 602
582 @param names list of paths (list of strings) 603 @param names list of paths (list of strings)
583 @return a tuple of string and list of strings (dirname, filenamelist) 604 @return a tuple of string and list of strings (dirname, filenamelist)
584 """ 605 """
585 dname = os.path.commonprefix(names) 606 dname = os.path.commonprefix(names)
592 else: 613 else:
593 return ("/", names) 614 return ("/", names)
594 615
595 def addArguments(self, args, argslist): 616 def addArguments(self, args, argslist):
596 """ 617 """
597 Protected method to add an argument list to the already present arguments. 618 Protected method to add an argument list to the already present
619 arguments.
598 620
599 @param args current arguments list (list of strings) 621 @param args current arguments list (list of strings)
600 @param argslist list of arguments (list of strings) 622 @param argslist list of arguments (list of strings)
601 """ 623 """
602 for arg in argslist: 624 for arg in argslist:
603 if arg != '': 625 if arg != '':
604 args.append(arg) 626 args.append(arg)
605 627
606 ############################################################################ 628 ###########################################################################
607 ## VCS status monitor thread related methods 629 ## VCS status monitor thread related methods
608 ############################################################################ 630 ###########################################################################
609 631
610 def __statusMonitorStatus(self, status, statusMsg): 632 def __statusMonitorStatus(self, status, statusMsg):
611 """ 633 """
612 Private method to receive the status monitor status. 634 Private method to receive the status monitor status.
613 635
636 658
637 @param project reference to the project object 659 @param project reference to the project object
638 @return reference to the monitor thread (QThread) 660 @return reference to the monitor thread (QThread)
639 """ 661 """
640 if project.pudata["VCSSTATUSMONITORINTERVAL"]: 662 if project.pudata["VCSSTATUSMONITORINTERVAL"]:
641 vcsStatusMonitorInterval = project.pudata["VCSSTATUSMONITORINTERVAL"][0] 663 vcsStatusMonitorInterval = project.pudata[
664 "VCSSTATUSMONITORINTERVAL"][0]
642 else: 665 else:
643 vcsStatusMonitorInterval = Preferences.getVCS("StatusMonitorInterval") 666 vcsStatusMonitorInterval = Preferences.getVCS(
667 "StatusMonitorInterval")
644 if vcsStatusMonitorInterval > 0: 668 if vcsStatusMonitorInterval > 0:
645 self.statusMonitorThread = \ 669 self.statusMonitorThread = self._createStatusMonitorThread(
646 self._createStatusMonitorThread(vcsStatusMonitorInterval, project) 670 vcsStatusMonitorInterval, project)
647 if self.statusMonitorThread is not None: 671 if self.statusMonitorThread is not None:
648 self.statusMonitorThread.vcsStatusMonitorData.connect( 672 self.statusMonitorThread.vcsStatusMonitorData.connect(
649 self.__statusMonitorData, Qt.QueuedConnection) 673 self.__statusMonitorData, Qt.QueuedConnection)
650 self.statusMonitorThread.vcsStatusMonitorStatus.connect( 674 self.statusMonitorThread.vcsStatusMonitorStatus.connect(
651 self.__statusMonitorStatus, Qt.QueuedConnection) 675 self.__statusMonitorStatus, Qt.QueuedConnection)
670 self.statusMonitorThread.wait(10000) 694 self.statusMonitorThread.wait(10000)
671 if not self.statusMonitorThread.isFinished(): 695 if not self.statusMonitorThread.isFinished():
672 self.statusMonitorThread.terminate() 696 self.statusMonitorThread.terminate()
673 self.statusMonitorThread.wait(10000) 697 self.statusMonitorThread.wait(10000)
674 self.statusMonitorThread = None 698 self.statusMonitorThread = None
675 self.__statusMonitorStatus("off", 699 self.__statusMonitorStatus(
700 "off",
676 self.trUtf8("Repository status checking is switched off")) 701 self.trUtf8("Repository status checking is switched off"))
677 702
678 def setStatusMonitorInterval(self, interval, project): 703 def setStatusMonitorInterval(self, interval, project):
679 """ 704 """
680 Public method to change the monitor interval. 705 Public method to change the monitor interval.
739 if self.statusMonitorThread is not None: 764 if self.statusMonitorThread is not None:
740 self.statusMonitorThread.clearCachedState(name) 765 self.statusMonitorThread.clearCachedState(name)
741 766
742 def _createStatusMonitorThread(self, interval, project): 767 def _createStatusMonitorThread(self, interval, project):
743 """ 768 """
744 Protected method to create an instance of the VCS status monitor thread. 769 Protected method to create an instance of the VCS status monitor
745 770 thread.
746 Note: This method should be overwritten in subclasses in order to support 771
747 VCS status monitoring. 772 Note: This method should be overwritten in subclasses in order to
748 773 support VCS status monitoring.
749 @param interval check interval for the monitor thread in seconds (integer) 774
775 @param interval check interval for the monitor thread in seconds
776 (integer)
750 @param project reference to the project object 777 @param project reference to the project object
751 @return reference to the monitor thread (QThread) 778 @return reference to the monitor thread (QThread)
752 """ 779 """
753 return None 780 return None

eric ide

mercurial