Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py

changeset 1047
b41a36b201e4
parent 1046
5dd14be5d6a1
child 1053
c54aa980ea8e
equal deleted inserted replaced
1046:5dd14be5d6a1 1047:b41a36b201e4
22 from .HgQueuesFoldDialog import HgQueuesFoldDialog 22 from .HgQueuesFoldDialog import HgQueuesFoldDialog
23 from .HgQueuesHeaderDialog import HgQueuesHeaderDialog 23 from .HgQueuesHeaderDialog import HgQueuesHeaderDialog
24 from .HgQueuesListGuardsDialog import HgQueuesListGuardsDialog 24 from .HgQueuesListGuardsDialog import HgQueuesListGuardsDialog
25 from .HgQueuesListAllGuardsDialog import HgQueuesListAllGuardsDialog 25 from .HgQueuesListAllGuardsDialog import HgQueuesListAllGuardsDialog
26 from .HgQueuesDefineGuardsDialog import HgQueuesDefineGuardsDialog 26 from .HgQueuesDefineGuardsDialog import HgQueuesDefineGuardsDialog
27 from .HgQueuesGuardsSelectionDialog import HgQueuesGuardsSelectionDialog
27 28
28 import Preferences 29 import Preferences
29 30
30 31
31 class Queues(QObject): 32 class Queues(QObject):
168 message = str( 169 message = str(
169 process.readAllStandardOutput(), 170 process.readAllStandardOutput(),
170 ioEncoding, 'replace') 171 ioEncoding, 'replace')
171 172
172 return message 173 return message
174
175 def getGuardsList(self, repodir, all=True):
176 """
177 Public method to get a list of all guards defined.
178
179 @param repodir directory name of the repository (string)
180 @param all flag indicating to get all guards (boolean)
181 @return sorted list of guards (list of strings)
182 """
183 guardsList = []
184
185 ioEncoding = Preferences.getSystem("IOEncoding")
186 process = QProcess()
187 args = []
188 args.append("qselect")
189 if all:
190 args.append("--series")
191
192 process.setWorkingDirectory(repodir)
193 process.start('hg', args)
194 procStarted = process.waitForStarted()
195 if procStarted:
196 finished = process.waitForFinished(30000)
197 if finished and process.exitCode() == 0:
198 output = \
199 str(process.readAllStandardOutput(), ioEncoding, 'replace')
200 for guard in output.splitlines():
201 guard = guard.strip()
202 if all:
203 guard = guard[1:]
204 if guard not in guardsList:
205 guardsList.append(guard)
206
207 return sorted(guardsList)
173 208
174 def hgQueueNewPatch(self, name): 209 def hgQueueNewPatch(self, name):
175 """ 210 """
176 Public method to create a new named patch. 211 Public method to create a new named patch.
177 212
536 571
537 patchnames = sorted( 572 patchnames = sorted(
538 self.__getPatchesList(repodir, Queues.SERIES_LIST)) 573 self.__getPatchesList(repodir, Queues.SERIES_LIST))
539 if patchnames: 574 if patchnames:
540 self.queuesDefineGuardsDialog = HgQueuesDefineGuardsDialog( 575 self.queuesDefineGuardsDialog = HgQueuesDefineGuardsDialog(
541 self.vcs, patchnames) 576 self.vcs, self, patchnames)
542 self.queuesDefineGuardsDialog.show() 577 self.queuesDefineGuardsDialog.show()
543 self.queuesDefineGuardsDialog.start(name) 578 self.queuesDefineGuardsDialog.start(name)
544 else: 579 else:
545 E5MessageBox.information(None, 580 E5MessageBox.information(None,
546 self.trUtf8("Define Guards"), 581 self.trUtf8("Define Guards"),
584 process.waitForFinished(30000) 619 process.waitForFinished(30000)
585 else: 620 else:
586 E5MessageBox.information(None, 621 E5MessageBox.information(None,
587 self.trUtf8("Drop All Guards"), 622 self.trUtf8("Drop All Guards"),
588 self.trUtf8("""No patches available to define guards for.""")) 623 self.trUtf8("""No patches available to define guards for."""))
624
625 def hgQueueGuardsSetActive(self, name):
626 """
627 Public method to set the active guards.
628
629 @param name file/directory name (string)
630 """
631 # find the root of the repo
632 repodir = self.vcs.splitPath(name)[0]
633 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
634 repodir = os.path.dirname(repodir)
635 if repodir == os.sep:
636 return
637
638 guardsList = self.getGuardsList(repodir)
639 if guardsList:
640 activeGuardsList = self.getGuardsList(repodir, all=False)
641 dlg = HgQueuesGuardsSelectionDialog(
642 guardsList, activeGuards=activeGuardsList, listOnly=False)
643 if dlg.exec_() == QDialog.Accepted:
644 guards = dlg.getData()
645 if guards:
646 args = []
647 args.append("qselect")
648 args.extend(guards)
649
650 dia = HgDialog(self.trUtf8('Set Active Guards'))
651 res = dia.startProcess(args, repodir)
652 if res:
653 dia.exec_()
654 else:
655 E5MessageBox.information(None,
656 self.trUtf8("Set Active Guards"),
657 self.trUtf8("""No guards available to select from."""))
658 return
659
660 def hgQueueGuardsDeactivate(self, name):
661 """
662 Public method to deactivate all active guards.
663
664 @param name file/directory name (string)
665 """
666 # find the root of the repo
667 repodir = self.vcs.splitPath(name)[0]
668 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
669 repodir = os.path.dirname(repodir)
670 if repodir == os.sep:
671 return
672
673 args = []
674 args.append("qselect")
675 args.append("--none")
676
677 dia = HgDialog(self.trUtf8('Deactivate Guards'))
678 res = dia.startProcess(args, repodir)
679 if res:
680 dia.exec_()
681
682 def hgQueueGuardsIdentifyActive(self, name):
683 """
684 Public method to list all active guards.
685
686 @param name file/directory name (string)
687 """
688 # find the root of the repo
689 repodir = self.vcs.splitPath(name)[0]
690 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
691 repodir = os.path.dirname(repodir)
692 if repodir == os.sep:
693 return
694
695 guardsList = self.getGuardsList(repodir, all=False)
696 if guardsList:
697 dlg = HgQueuesGuardsSelectionDialog(guardsList, listOnly=True)
698 dlg.exec_()

eric ide

mercurial