VCS/VersionControl.py

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

eric ide

mercurial