Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3302
e92f0dd51979
child 3591
2f2a4a76dd22
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
7 Module implementing the queues extension interface. 7 Module implementing the queues extension interface.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 try: 11 try:
12 str = unicode # __IGNORE_WARNING__ 12 str = unicode
13 except (NameError): 13 except NameError:
14 pass 14 pass
15 15
16 import os 16 import os
17 17
18 from PyQt4.QtCore import QProcess 18 from PyQt4.QtCore import QProcess
20 20
21 from E5Gui import E5MessageBox 21 from E5Gui import E5MessageBox
22 22
23 from ..HgExtension import HgExtension 23 from ..HgExtension import HgExtension
24 from ..HgDialog import HgDialog 24 from ..HgDialog import HgDialog
25
26 import Preferences
27 25
28 26
29 class Queues(HgExtension): 27 class Queues(HgExtension):
30 """ 28 """
31 Class implementing the queues extension interface. 29 Class implementing the queues extension interface.
91 @return list of patches (list of string) 89 @return list of patches (list of string)
92 @exception ValueError raised to indicate an invalid patch list type 90 @exception ValueError raised to indicate an invalid patch list type
93 """ 91 """
94 patchesList = [] 92 patchesList = []
95 93
96 args = []
97 if listType == Queues.APPLIED_LIST: 94 if listType == Queues.APPLIED_LIST:
98 args.append("qapplied") 95 args = self.vcs.initCommand("qapplied")
99 elif listType == Queues.UNAPPLIED_LIST: 96 elif listType == Queues.UNAPPLIED_LIST:
100 args.append("qunapplied") 97 args = self.vcs.initCommand("qunapplied")
101 elif listType == Queues.SERIES_LIST: 98 elif listType == Queues.SERIES_LIST:
102 args.append("qseries") 99 args = self.vcs.initCommand("qseries")
103 else: 100 else:
104 raise ValueError("illegal value for listType") 101 raise ValueError("illegal value for listType")
105 if withSummary: 102 if withSummary:
106 args.append("--summary") 103 args.append("--summary")
107 104
108 client = self.vcs.getClient() 105 client = self.vcs.getClient()
109 output = "" 106 output = ""
110 if client: 107 if client:
111 output = client.runcommand(args)[0] 108 output = client.runcommand(args)[0]
112 else: 109 else:
113 ioEncoding = Preferences.getSystem("IOEncoding")
114 process = QProcess() 110 process = QProcess()
115 process.setWorkingDirectory(repodir) 111 process.setWorkingDirectory(repodir)
116 process.start('hg', args) 112 process.start('hg', args)
117 procStarted = process.waitForStarted(5000) 113 procStarted = process.waitForStarted(5000)
118 if procStarted: 114 if procStarted:
119 finished = process.waitForFinished(30000) 115 finished = process.waitForFinished(30000)
120 if finished and process.exitCode() == 0: 116 if finished and process.exitCode() == 0:
121 output = str( 117 output = str(process.readAllStandardOutput(),
122 process.readAllStandardOutput(), ioEncoding, 'replace') 118 self.vcs.getEncoding(), 'replace')
123 119
124 for line in output.splitlines(): 120 for line in output.splitlines():
125 if withSummary: 121 if withSummary:
126 li = line.strip().split(": ") 122 li = line.strip().split(": ")
127 if len(li) == 1: 123 if len(li) == 1:
141 @param repodir directory name of the repository (string) 137 @param repodir directory name of the repository (string)
142 @return name of the current patch (string) 138 @return name of the current patch (string)
143 """ 139 """
144 currentPatch = "" 140 currentPatch = ""
145 141
146 args = [] 142 args = self.vcs.initCommand("qtop")
147 args.append("qtop")
148 143
149 client = self.vcs.getClient() 144 client = self.vcs.getClient()
150 if client: 145 if client:
151 currentPatch = client.runcommand(args)[0].strip() 146 currentPatch = client.runcommand(args)[0].strip()
152 else: 147 else:
153 ioEncoding = Preferences.getSystem("IOEncoding")
154 process = QProcess() 148 process = QProcess()
155 process.setWorkingDirectory(repodir) 149 process.setWorkingDirectory(repodir)
156 process.start('hg', args) 150 process.start('hg', args)
157 procStarted = process.waitForStarted(5000) 151 procStarted = process.waitForStarted(5000)
158 if procStarted: 152 if procStarted:
159 finished = process.waitForFinished(30000) 153 finished = process.waitForFinished(30000)
160 if finished and process.exitCode() == 0: 154 if finished and process.exitCode() == 0:
161 currentPatch = str( 155 currentPatch = str(process.readAllStandardOutput(),
162 process.readAllStandardOutput(), 156 self.vcs.getEncoding(),
163 ioEncoding, 'replace').strip() 157 'replace').strip()
164 158
165 return currentPatch 159 return currentPatch
166 160
167 def __getCommitMessage(self, repodir): 161 def __getCommitMessage(self, repodir):
168 """ 162 """
171 @param repodir directory name of the repository (string) 165 @param repodir directory name of the repository (string)
172 @return name of the current patch (string) 166 @return name of the current patch (string)
173 """ 167 """
174 message = "" 168 message = ""
175 169
176 args = [] 170 args = self.vcs.initCommand("qheader")
177 args.append("qheader")
178 171
179 client = self.vcs.getClient() 172 client = self.vcs.getClient()
180 if client: 173 if client:
181 message = client.runcommand(args)[0] 174 message = client.runcommand(args)[0]
182 else: 175 else:
183 ioEncoding = Preferences.getSystem("IOEncoding")
184 process = QProcess() 176 process = QProcess()
185 process.setWorkingDirectory(repodir) 177 process.setWorkingDirectory(repodir)
186 process.start('hg', args) 178 process.start('hg', args)
187 procStarted = process.waitForStarted(5000) 179 procStarted = process.waitForStarted(5000)
188 if procStarted: 180 if procStarted:
189 finished = process.waitForFinished(30000) 181 finished = process.waitForFinished(30000)
190 if finished and process.exitCode() == 0: 182 if finished and process.exitCode() == 0:
191 message = str( 183 message = str(process.readAllStandardOutput(),
192 process.readAllStandardOutput(), 184 self.vcs.getEncoding(), 'replace')
193 ioEncoding, 'replace')
194 185
195 return message 186 return message
196 187
197 def getGuardsList(self, repodir, all=True): 188 def getGuardsList(self, repodir, all=True):
198 """ 189 """
202 @param all flag indicating to get all guards (boolean) 193 @param all flag indicating to get all guards (boolean)
203 @return sorted list of guards (list of strings) 194 @return sorted list of guards (list of strings)
204 """ 195 """
205 guardsList = [] 196 guardsList = []
206 197
207 args = [] 198 args = self.vcs.initCommand("qselect")
208 args.append("qselect")
209 if all: 199 if all:
210 args.append("--series") 200 args.append("--series")
211 201
212 client = self.vcs.getClient() 202 client = self.vcs.getClient()
213 output = "" 203 output = ""
214 if client: 204 if client:
215 output = client.runcommand(args)[0] 205 output = client.runcommand(args)[0]
216 else: 206 else:
217 ioEncoding = Preferences.getSystem("IOEncoding")
218 process = QProcess() 207 process = QProcess()
219 process.setWorkingDirectory(repodir) 208 process.setWorkingDirectory(repodir)
220 process.start('hg', args) 209 process.start('hg', args)
221 procStarted = process.waitForStarted(5000) 210 procStarted = process.waitForStarted(5000)
222 if procStarted: 211 if procStarted:
223 finished = process.waitForFinished(30000) 212 finished = process.waitForFinished(30000)
224 if finished and process.exitCode() == 0: 213 if finished and process.exitCode() == 0:
225 output = str( 214 output = str(process.readAllStandardOutput(),
226 process.readAllStandardOutput(), ioEncoding, 'replace') 215 self.vcs.getEncoding(), 'replace')
227 216
228 for guard in output.splitlines(): 217 for guard in output.splitlines():
229 guard = guard.strip() 218 guard = guard.strip()
230 if all: 219 if all:
231 guard = guard[1:] 220 guard = guard[1:]
251 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.NEW_MODE) 240 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.NEW_MODE)
252 if dlg.exec_() == QDialog.Accepted: 241 if dlg.exec_() == QDialog.Accepted:
253 name, message, (userData, currentUser, userName), \ 242 name, message, (userData, currentUser, userName), \
254 (dateData, currentDate, dateStr) = dlg.getData() 243 (dateData, currentDate, dateStr) = dlg.getData()
255 244
256 args = [] 245 args = self.vcs.initCommand("qnew")
257 args.append("qnew")
258 if message != "": 246 if message != "":
259 args.append("--message") 247 args.append("--message")
260 args.append(message) 248 args.append(message)
261 if userData: 249 if userData:
262 if currentUser: 250 if currentUser:
270 else: 258 else:
271 args.append("--date") 259 args.append("--date")
272 args.append(dateStr) 260 args.append(dateStr)
273 args.append(name) 261 args.append(name)
274 262
275 dia = HgDialog(self.trUtf8('New Patch'), self.vcs) 263 dia = HgDialog(self.tr('New Patch'), self.vcs)
276 res = dia.startProcess(args, repodir) 264 res = dia.startProcess(args, repodir)
277 if res: 265 if res:
278 dia.exec_() 266 dia.exec_()
279 self.vcs.checkVCSStatus() 267 self.vcs.checkVCSStatus()
280 268
291 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 279 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
292 repodir = os.path.dirname(repodir) 280 repodir = os.path.dirname(repodir)
293 if os.path.splitdrive(repodir)[1] == os.sep: 281 if os.path.splitdrive(repodir)[1] == os.sep:
294 return 282 return
295 283
296 args = [] 284 args = self.vcs.initCommand("qrefresh")
297 args.append("qrefresh")
298 285
299 if editMessage: 286 if editMessage:
300 currentMessage = self.__getCommitMessage(repodir) 287 currentMessage = self.__getCommitMessage(repodir)
301 from .HgQueuesNewPatchDialog import HgQueuesNewPatchDialog 288 from .HgQueuesNewPatchDialog import HgQueuesNewPatchDialog
302 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.REFRESH_MODE, 289 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.REFRESH_MODE,
320 args.append("--date") 307 args.append("--date")
321 args.append(dateStr) 308 args.append(dateStr)
322 else: 309 else:
323 return 310 return
324 311
325 dia = HgDialog(self.trUtf8('Update Current Patch'), self.vcs) 312 dia = HgDialog(self.tr('Update Current Patch'), self.vcs)
326 res = dia.startProcess(args, repodir) 313 res = dia.startProcess(args, repodir)
327 if res: 314 if res:
328 dia.exec_() 315 dia.exec_()
329 self.vcs.checkVCSStatus() 316 self.vcs.checkVCSStatus()
330 317
373 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 360 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
374 repodir = os.path.dirname(repodir) 361 repodir = os.path.dirname(repodir)
375 if os.path.splitdrive(repodir)[1] == os.sep: 362 if os.path.splitdrive(repodir)[1] == os.sep:
376 return False 363 return False
377 364
378 args = []
379 if operation == Queues.POP: 365 if operation == Queues.POP:
380 args.append("qpop") 366 args = self.vcs.initCommand("qpop")
381 title = self.trUtf8("Pop Patches") 367 title = self.tr("Pop Patches")
382 listType = Queues.APPLIED_LIST 368 listType = Queues.APPLIED_LIST
383 elif operation == Queues.PUSH: 369 elif operation == Queues.PUSH:
384 args.append("qpush") 370 args = self.vcs.initCommand("qpush")
385 title = self.trUtf8("Push Patches") 371 title = self.tr("Push Patches")
386 listType = Queues.UNAPPLIED_LIST 372 listType = Queues.UNAPPLIED_LIST
387 elif operation == Queues.GOTO: 373 elif operation == Queues.GOTO:
388 args.append("qgoto") 374 args = self.vcs.initCommand("qgoto")
389 title = self.trUtf8("Go to Patch") 375 title = self.tr("Go to Patch")
390 listType = Queues.SERIES_LIST 376 listType = Queues.SERIES_LIST
391 else: 377 else:
392 raise ValueError("illegal value for operation") 378 raise ValueError("illegal value for operation")
393 args.append("-v") 379 args.append("-v")
394 if force: 380 if force:
398 elif named or operation == Queues.GOTO: 384 elif named or operation == Queues.GOTO:
399 patchnames = self.__getPatchesList(repodir, listType) 385 patchnames = self.__getPatchesList(repodir, listType)
400 if patchnames: 386 if patchnames:
401 patch, ok = QInputDialog.getItem( 387 patch, ok = QInputDialog.getItem(
402 None, 388 None,
403 self.trUtf8("Select Patch"), 389 self.tr("Select Patch"),
404 self.trUtf8("Select the target patch name:"), 390 self.tr("Select the target patch name:"),
405 patchnames, 391 patchnames,
406 0, False) 392 0, False)
407 if ok and patch: 393 if ok and patch:
408 args.append(patch) 394 args.append(patch)
409 else: 395 else:
410 return False 396 return False
411 else: 397 else:
412 E5MessageBox.information( 398 E5MessageBox.information(
413 None, 399 None,
414 self.trUtf8("Select Patch"), 400 self.tr("Select Patch"),
415 self.trUtf8("""No patches to select from.""")) 401 self.tr("""No patches to select from."""))
416 return False 402 return False
417 403
418 dia = HgDialog(title, self.vcs) 404 dia = HgDialog(title, self.vcs)
419 res = dia.startProcess(args, repodir) 405 res = dia.startProcess(args, repodir)
420 if res: 406 if res:
445 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 431 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
446 repodir = os.path.dirname(repodir) 432 repodir = os.path.dirname(repodir)
447 if os.path.splitdrive(repodir)[1] == os.sep: 433 if os.path.splitdrive(repodir)[1] == os.sep:
448 return 434 return
449 435
450 args = [] 436 args = self.vcs.initCommand("qfinish")
451 args.append("qfinish")
452 args.append("--applied") 437 args.append("--applied")
453 438
454 dia = HgDialog(self.trUtf8('Finish Applied Patches'), self.vcs) 439 dia = HgDialog(self.tr('Finish Applied Patches'), self.vcs)
455 res = dia.startProcess(args, repodir) 440 res = dia.startProcess(args, repodir)
456 if res: 441 if res:
457 dia.exec_() 442 dia.exec_()
458 self.vcs.checkVCSStatus() 443 self.vcs.checkVCSStatus()
459 444
468 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 453 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
469 repodir = os.path.dirname(repodir) 454 repodir = os.path.dirname(repodir)
470 if os.path.splitdrive(repodir)[1] == os.sep: 455 if os.path.splitdrive(repodir)[1] == os.sep:
471 return 456 return
472 457
473 args = [] 458 args = self.vcs.initCommand("qrename")
474 args.append("qrename")
475 patchnames = sorted(self.__getPatchesList(repodir, Queues.SERIES_LIST)) 459 patchnames = sorted(self.__getPatchesList(repodir, Queues.SERIES_LIST))
476 if patchnames: 460 if patchnames:
477 currentPatch = self.__getCurrentPatch(repodir) 461 currentPatch = self.__getCurrentPatch(repodir)
478 if currentPatch: 462 if currentPatch:
479 from .HgQueuesRenamePatchDialog import \ 463 from .HgQueuesRenamePatchDialog import \
483 newName, selectedPatch = dlg.getData() 467 newName, selectedPatch = dlg.getData()
484 if selectedPatch: 468 if selectedPatch:
485 args.append(selectedPatch) 469 args.append(selectedPatch)
486 args.append(newName) 470 args.append(newName)
487 471
488 dia = HgDialog(self.trUtf8("Rename Patch"), self.vcs) 472 dia = HgDialog(self.tr("Rename Patch"), self.vcs)
489 res = dia.startProcess(args, repodir) 473 res = dia.startProcess(args, repodir)
490 if res: 474 if res:
491 dia.exec_() 475 dia.exec_()
492 476
493 def hgQueueDeletePatch(self, name): 477 def hgQueueDeletePatch(self, name):
501 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 485 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
502 repodir = os.path.dirname(repodir) 486 repodir = os.path.dirname(repodir)
503 if os.path.splitdrive(repodir)[1] == os.sep: 487 if os.path.splitdrive(repodir)[1] == os.sep:
504 return 488 return
505 489
506 args = [] 490 args = self.vcs.initCommand("qdelete")
507 args.append("qdelete")
508 patchnames = sorted(self.__getPatchesList(repodir, 491 patchnames = sorted(self.__getPatchesList(repodir,
509 Queues.UNAPPLIED_LIST)) 492 Queues.UNAPPLIED_LIST))
510 if patchnames: 493 if patchnames:
511 patch, ok = QInputDialog.getItem( 494 patch, ok = QInputDialog.getItem(
512 None, 495 None,
513 self.trUtf8("Select Patch"), 496 self.tr("Select Patch"),
514 self.trUtf8("Select the patch to be deleted:"), 497 self.tr("Select the patch to be deleted:"),
515 patchnames, 498 patchnames,
516 0, False) 499 0, False)
517 if ok and patch: 500 if ok and patch:
518 args.append(patch) 501 args.append(patch)
519 502
520 dia = HgDialog(self.trUtf8("Delete Patch"), self.vcs) 503 dia = HgDialog(self.tr("Delete Patch"), self.vcs)
521 res = dia.startProcess(args, repodir) 504 res = dia.startProcess(args, repodir)
522 if res: 505 if res:
523 dia.exec_() 506 dia.exec_()
524 else: 507 else:
525 E5MessageBox.information( 508 E5MessageBox.information(
526 None, 509 None,
527 self.trUtf8("Select Patch"), 510 self.tr("Select Patch"),
528 self.trUtf8("""No patches to select from.""")) 511 self.tr("""No patches to select from."""))
529 512
530 def hgQueueFoldUnappliedPatches(self, name): 513 def hgQueueFoldUnappliedPatches(self, name):
531 """ 514 """
532 Public method to fold patches into the current patch. 515 Public method to fold patches into the current patch.
533 516
538 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 521 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
539 repodir = os.path.dirname(repodir) 522 repodir = os.path.dirname(repodir)
540 if os.path.splitdrive(repodir)[1] == os.sep: 523 if os.path.splitdrive(repodir)[1] == os.sep:
541 return 524 return
542 525
543 args = [] 526 args = self.vcs.initCommand("qfold")
544 args.append("qfold")
545 patchnames = sorted( 527 patchnames = sorted(
546 self.__getPatchesList(repodir, Queues.UNAPPLIED_LIST, 528 self.__getPatchesList(repodir, Queues.UNAPPLIED_LIST,
547 withSummary=True)) 529 withSummary=True))
548 if patchnames: 530 if patchnames:
549 from .HgQueuesFoldDialog import HgQueuesFoldDialog 531 from .HgQueuesFoldDialog import HgQueuesFoldDialog
554 args.append("--message") 536 args.append("--message")
555 args.append(message) 537 args.append(message)
556 if patchesList: 538 if patchesList:
557 args.extend(patchesList) 539 args.extend(patchesList)
558 540
559 dia = HgDialog(self.trUtf8("Fold Patches"), self.vcs) 541 dia = HgDialog(self.tr("Fold Patches"), self.vcs)
560 res = dia.startProcess(args, repodir) 542 res = dia.startProcess(args, repodir)
561 if res: 543 if res:
562 dia.exec_() 544 dia.exec_()
563 else: 545 else:
564 E5MessageBox.information( 546 E5MessageBox.information(
565 None, 547 None,
566 self.trUtf8("Fold Patches"), 548 self.tr("Fold Patches"),
567 self.trUtf8("""No patches selected.""")) 549 self.tr("""No patches selected."""))
568 else: 550 else:
569 E5MessageBox.information( 551 E5MessageBox.information(
570 None, 552 None,
571 self.trUtf8("Fold Patches"), 553 self.tr("Fold Patches"),
572 self.trUtf8("""No patches available to be folded.""")) 554 self.tr("""No patches available to be folded."""))
573 555
574 def hgQueueGuardsList(self, name): 556 def hgQueueGuardsList(self, name):
575 """ 557 """
576 Public method to list the guards for the current or a named patch. 558 Public method to list the guards for the current or a named patch.
577 559
593 self.queuesListGuardsDialog.show() 575 self.queuesListGuardsDialog.show()
594 self.queuesListGuardsDialog.start(name) 576 self.queuesListGuardsDialog.start(name)
595 else: 577 else:
596 E5MessageBox.information( 578 E5MessageBox.information(
597 None, 579 None,
598 self.trUtf8("List Guards"), 580 self.tr("List Guards"),
599 self.trUtf8("""No patches available to list guards for.""")) 581 self.tr("""No patches available to list guards for."""))
600 582
601 def hgQueueGuardsListAll(self, name): 583 def hgQueueGuardsListAll(self, name):
602 """ 584 """
603 Public method to list all guards of all patches. 585 Public method to list all guards of all patches.
604 586
631 self.queuesDefineGuardsDialog.show() 613 self.queuesDefineGuardsDialog.show()
632 self.queuesDefineGuardsDialog.start(name) 614 self.queuesDefineGuardsDialog.start(name)
633 else: 615 else:
634 E5MessageBox.information( 616 E5MessageBox.information(
635 None, 617 None,
636 self.trUtf8("Define Guards"), 618 self.tr("Define Guards"),
637 self.trUtf8("""No patches available to define guards for.""")) 619 self.tr("""No patches available to define guards for."""))
638 620
639 def hgQueueGuardsDropAll(self, name): 621 def hgQueueGuardsDropAll(self, name):
640 """ 622 """
641 Public method to drop all guards of the current or a named patch. 623 Public method to drop all guards of the current or a named patch.
642 624
652 patchnames = sorted( 634 patchnames = sorted(
653 self.__getPatchesList(repodir, Queues.SERIES_LIST)) 635 self.__getPatchesList(repodir, Queues.SERIES_LIST))
654 if patchnames: 636 if patchnames:
655 patch, ok = QInputDialog.getItem( 637 patch, ok = QInputDialog.getItem(
656 None, 638 None,
657 self.trUtf8("Drop All Guards"), 639 self.tr("Drop All Guards"),
658 self.trUtf8("Select the patch to drop guards for" 640 self.tr("Select the patch to drop guards for"
659 " (leave empty for the current patch):"), 641 " (leave empty for the current patch):"),
660 [""] + patchnames, 642 [""] + patchnames,
661 0, False) 643 0, False)
662 if ok: 644 if ok:
663 args = [] 645 args = self.vcs.initCommand("qguard")
664 args.append("qguard")
665 if patch: 646 if patch:
666 args.append(patch) 647 args.append(patch)
667 args.append("--none") 648 args.append("--none")
668 649
669 client = self.vcs.getClient() 650 client = self.vcs.getClient()
677 if procStarted: 658 if procStarted:
678 process.waitForFinished(30000) 659 process.waitForFinished(30000)
679 else: 660 else:
680 E5MessageBox.information( 661 E5MessageBox.information(
681 None, 662 None,
682 self.trUtf8("Drop All Guards"), 663 self.tr("Drop All Guards"),
683 self.trUtf8("""No patches available to define guards for.""")) 664 self.tr("""No patches available to define guards for."""))
684 665
685 def hgQueueGuardsSetActive(self, name): 666 def hgQueueGuardsSetActive(self, name):
686 """ 667 """
687 Public method to set the active guards. 668 Public method to set the active guards.
688 669
703 dlg = HgQueuesGuardsSelectionDialog( 684 dlg = HgQueuesGuardsSelectionDialog(
704 guardsList, activeGuards=activeGuardsList, listOnly=False) 685 guardsList, activeGuards=activeGuardsList, listOnly=False)
705 if dlg.exec_() == QDialog.Accepted: 686 if dlg.exec_() == QDialog.Accepted:
706 guards = dlg.getData() 687 guards = dlg.getData()
707 if guards: 688 if guards:
708 args = [] 689 args = self.vcs.initCommand("qselect")
709 args.append("qselect")
710 args.extend(guards) 690 args.extend(guards)
711 691
712 dia = HgDialog(self.trUtf8('Set Active Guards'), self.vcs) 692 dia = HgDialog(self.tr('Set Active Guards'), self.vcs)
713 res = dia.startProcess(args, repodir) 693 res = dia.startProcess(args, repodir)
714 if res: 694 if res:
715 dia.exec_() 695 dia.exec_()
716 else: 696 else:
717 E5MessageBox.information( 697 E5MessageBox.information(
718 None, 698 None,
719 self.trUtf8("Set Active Guards"), 699 self.tr("Set Active Guards"),
720 self.trUtf8("""No guards available to select from.""")) 700 self.tr("""No guards available to select from."""))
721 return 701 return
722 702
723 def hgQueueGuardsDeactivate(self, name): 703 def hgQueueGuardsDeactivate(self, name):
724 """ 704 """
725 Public method to deactivate all active guards. 705 Public method to deactivate all active guards.
731 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 711 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
732 repodir = os.path.dirname(repodir) 712 repodir = os.path.dirname(repodir)
733 if os.path.splitdrive(repodir)[1] == os.sep: 713 if os.path.splitdrive(repodir)[1] == os.sep:
734 return 714 return
735 715
736 args = [] 716 args = self.vcs.initCommand("qselect")
737 args.append("qselect")
738 args.append("--none") 717 args.append("--none")
739 718
740 dia = HgDialog(self.trUtf8('Deactivate Guards'), self.vcs) 719 dia = HgDialog(self.tr('Deactivate Guards'), self.vcs)
741 res = dia.startProcess(args, repodir) 720 res = dia.startProcess(args, repodir)
742 if res: 721 if res:
743 dia.exec_() 722 dia.exec_()
744 723
745 def hgQueueGuardsIdentifyActive(self, name): 724 def hgQueueGuardsIdentifyActive(self, name):
775 repodir = os.path.dirname(repodir) 754 repodir = os.path.dirname(repodir)
776 if os.path.splitdrive(repodir)[1] == os.sep: 755 if os.path.splitdrive(repodir)[1] == os.sep:
777 return 756 return
778 757
779 if isCreate: 758 if isCreate:
780 title = self.trUtf8("Create New Queue") 759 title = self.tr("Create New Queue")
781 else: 760 else:
782 title = self.trUtf8("Rename Active Queue") 761 title = self.tr("Rename Active Queue")
783 from .HgQueuesQueueManagementDialog import \ 762 from .HgQueuesQueueManagementDialog import \
784 HgQueuesQueueManagementDialog 763 HgQueuesQueueManagementDialog
785 dlg = HgQueuesQueueManagementDialog( 764 dlg = HgQueuesQueueManagementDialog(
786 HgQueuesQueueManagementDialog.NAME_INPUT, 765 HgQueuesQueueManagementDialog.NAME_INPUT,
787 title, False, repodir, self.vcs) 766 title, False, repodir, self.vcs)
788 if dlg.exec_() == QDialog.Accepted: 767 if dlg.exec_() == QDialog.Accepted:
789 queueName = dlg.getData() 768 queueName = dlg.getData()
790 if queueName: 769 if queueName:
791 args = [] 770 args = self.vcs.initCommand("qqueue")
792 args.append("qqueue")
793 if isCreate: 771 if isCreate:
794 args.append("--create") 772 args.append("--create")
795 else: 773 else:
796 args.append("--rename") 774 args.append("--rename")
797 args.append(queueName) 775 args.append(queueName)
799 client = self.vcs.getClient() 777 client = self.vcs.getClient()
800 error = "" 778 error = ""
801 if client: 779 if client:
802 error = client.runcommand(args)[1] 780 error = client.runcommand(args)[1]
803 else: 781 else:
804 ioEncoding = Preferences.getSystem("IOEncoding")
805 process = QProcess() 782 process = QProcess()
806 process.setWorkingDirectory(repodir) 783 process.setWorkingDirectory(repodir)
807 process.start('hg', args) 784 process.start('hg', args)
808 procStarted = process.waitForStarted(5000) 785 procStarted = process.waitForStarted(5000)
809 if procStarted: 786 if procStarted:
810 finished = process.waitForFinished(30000) 787 finished = process.waitForFinished(30000)
811 if finished: 788 if finished:
812 if process.exitCode() != 0: 789 if process.exitCode() != 0:
813 error = \ 790 error = str(process.readAllStandardError(),
814 str(process.readAllStandardError(), 791 self.vcs.getEncoding(), 'replace')
815 ioEncoding, 'replace')
816 792
817 if error: 793 if error:
818 if isCreate: 794 if isCreate:
819 errMsg = self.trUtf8( 795 errMsg = self.tr(
820 "Error while creating a new queue.") 796 "Error while creating a new queue.")
821 else: 797 else:
822 errMsg = self.trUtf8( 798 errMsg = self.tr(
823 "Error while renaming the active queue.") 799 "Error while renaming the active queue.")
824 E5MessageBox.warning( 800 E5MessageBox.warning(
825 None, 801 None,
826 title, 802 title,
827 """<p>{0}</p><p>{1}</p>""".format(errMsg, error)) 803 """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
846 repodir = os.path.dirname(repodir) 822 repodir = os.path.dirname(repodir)
847 if os.path.splitdrive(repodir)[1] == os.sep: 823 if os.path.splitdrive(repodir)[1] == os.sep:
848 return 824 return
849 825
850 if operation == Queues.QUEUE_PURGE: 826 if operation == Queues.QUEUE_PURGE:
851 title = self.trUtf8("Purge Queue") 827 title = self.tr("Purge Queue")
852 elif operation == Queues.QUEUE_DELETE: 828 elif operation == Queues.QUEUE_DELETE:
853 title = self.trUtf8("Delete Queue") 829 title = self.tr("Delete Queue")
854 elif operation == Queues.QUEUE_ACTIVATE: 830 elif operation == Queues.QUEUE_ACTIVATE:
855 title = self.trUtf8("Activate Queue") 831 title = self.tr("Activate Queue")
856 else: 832 else:
857 raise ValueError("illegal value for operation") 833 raise ValueError("illegal value for operation")
858 834
859 from .HgQueuesQueueManagementDialog import \ 835 from .HgQueuesQueueManagementDialog import \
860 HgQueuesQueueManagementDialog 836 HgQueuesQueueManagementDialog
862 HgQueuesQueueManagementDialog.QUEUE_INPUT, 838 HgQueuesQueueManagementDialog.QUEUE_INPUT,
863 title, True, repodir, self.vcs) 839 title, True, repodir, self.vcs)
864 if dlg.exec_() == QDialog.Accepted: 840 if dlg.exec_() == QDialog.Accepted:
865 queueName = dlg.getData() 841 queueName = dlg.getData()
866 if queueName: 842 if queueName:
867 args = [] 843 args = self.vcs.initCommand("qqueue")
868 args.append("qqueue")
869 if operation == Queues.QUEUE_PURGE: 844 if operation == Queues.QUEUE_PURGE:
870 args.append("--purge") 845 args.append("--purge")
871 elif operation == Queues.QUEUE_DELETE: 846 elif operation == Queues.QUEUE_DELETE:
872 args.append("--delete") 847 args.append("--delete")
873 args.append(queueName) 848 args.append(queueName)
875 client = self.vcs.getClient() 850 client = self.vcs.getClient()
876 error = "" 851 error = ""
877 if client: 852 if client:
878 error = client.runcommand(args)[1] 853 error = client.runcommand(args)[1]
879 else: 854 else:
880 ioEncoding = Preferences.getSystem("IOEncoding")
881 process = QProcess() 855 process = QProcess()
882 process.setWorkingDirectory(repodir) 856 process.setWorkingDirectory(repodir)
883 process.start('hg', args) 857 process.start('hg', args)
884 procStarted = process.waitForStarted(5000) 858 procStarted = process.waitForStarted(5000)
885 if procStarted: 859 if procStarted:
886 finished = process.waitForFinished(30000) 860 finished = process.waitForFinished(30000)
887 if finished: 861 if finished:
888 if process.exitCode() != 0: 862 if process.exitCode() != 0:
889 error = \ 863 error = str(process.readAllStandardError(),
890 str(process.readAllStandardError(), 864 self.vcs.getEncoding(), 'replace')
891 ioEncoding, 'replace')
892 865
893 if error: 866 if error:
894 if operation == Queues.QUEUE_PURGE: 867 if operation == Queues.QUEUE_PURGE:
895 errMsg = self.trUtf8("Error while purging the queue.") 868 errMsg = self.tr("Error while purging the queue.")
896 elif operation == Queues.QUEUE_DELETE: 869 elif operation == Queues.QUEUE_DELETE:
897 errMsg = self.trUtf8("Error while deleting the queue.") 870 errMsg = self.tr("Error while deleting the queue.")
898 elif operation == Queues.QUEUE_ACTIVATE: 871 elif operation == Queues.QUEUE_ACTIVATE:
899 errMsg = self.trUtf8( 872 errMsg = self.tr(
900 "Error while setting the active queue.") 873 "Error while setting the active queue.")
901 E5MessageBox.warning( 874 E5MessageBox.warning(
902 None, 875 None,
903 title, 876 title,
904 """<p>{0}</p><p>{1}</p>""".format(errMsg, error)) 877 """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
922 895
923 from .HgQueuesQueueManagementDialog import \ 896 from .HgQueuesQueueManagementDialog import \
924 HgQueuesQueueManagementDialog 897 HgQueuesQueueManagementDialog
925 self.queuesListQueuesDialog = HgQueuesQueueManagementDialog( 898 self.queuesListQueuesDialog = HgQueuesQueueManagementDialog(
926 HgQueuesQueueManagementDialog.NO_INPUT, 899 HgQueuesQueueManagementDialog.NO_INPUT,
927 self.trUtf8("Available Queues"), 900 self.tr("Available Queues"),
928 False, repodir, self.vcs) 901 False, repodir, self.vcs)
929 self.queuesListQueuesDialog.show() 902 self.queuesListQueuesDialog.show()
930 903
931 def hgQueueInit(self, name): 904 def hgQueueInit(self, name):
932 """ 905 """
939 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 912 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
940 repodir = os.path.dirname(repodir) 913 repodir = os.path.dirname(repodir)
941 if os.path.splitdrive(repodir)[1] == os.sep: 914 if os.path.splitdrive(repodir)[1] == os.sep:
942 return 915 return
943 916
944 args = [] 917 args = self.vcs.initCommand("init")
945 args.append('init')
946 args.append('--mq') 918 args.append('--mq')
947 args.append(repodir) 919 args.append(repodir)
948 # init is not possible with the command server 920 # init is not possible with the command server
949 dia = HgDialog( 921 dia = HgDialog(
950 self.trUtf8('Initializing new queue repository'), self.vcs) 922 self.tr('Initializing new queue repository'), self.vcs)
951 res = dia.startProcess(args) 923 res = dia.startProcess(args)
952 if res: 924 if res:
953 dia.exec_() 925 dia.exec_()
954 926
955 def hgQueueStatus(self, name): 927 def hgQueueStatus(self, name):

eric ide

mercurial