15 from E5Gui import E5MessageBox |
15 from E5Gui import E5MessageBox |
16 |
16 |
17 from ..HgExtension import HgExtension |
17 from ..HgExtension import HgExtension |
18 from ..HgDialog import HgDialog |
18 from ..HgDialog import HgDialog |
19 |
19 |
20 import Preferences |
|
21 |
|
22 |
20 |
23 class Queues(HgExtension): |
21 class Queues(HgExtension): |
24 """ |
22 """ |
25 Class implementing the queues extension interface. |
23 Class implementing the queues extension interface. |
26 """ |
24 """ |
85 @return list of patches (list of string) |
83 @return list of patches (list of string) |
86 @exception ValueError raised to indicate an invalid patch list type |
84 @exception ValueError raised to indicate an invalid patch list type |
87 """ |
85 """ |
88 patchesList = [] |
86 patchesList = [] |
89 |
87 |
90 args = [] |
|
91 if listType == Queues.APPLIED_LIST: |
88 if listType == Queues.APPLIED_LIST: |
92 args.append("qapplied") |
89 args = self.vcs.initCommand("qapplied") |
93 elif listType == Queues.UNAPPLIED_LIST: |
90 elif listType == Queues.UNAPPLIED_LIST: |
94 args.append("qunapplied") |
91 args = self.vcs.initCommand("qunapplied") |
95 elif listType == Queues.SERIES_LIST: |
92 elif listType == Queues.SERIES_LIST: |
96 args.append("qseries") |
93 args = self.vcs.initCommand("qseries") |
97 else: |
94 else: |
98 raise ValueError("illegal value for listType") |
95 raise ValueError("illegal value for listType") |
99 if withSummary: |
96 if withSummary: |
100 args.append("--summary") |
97 args.append("--summary") |
101 |
98 |
102 client = self.vcs.getClient() |
99 client = self.vcs.getClient() |
103 output = "" |
100 output = "" |
104 if client: |
101 if client: |
105 output = client.runcommand(args)[0] |
102 output = client.runcommand(args)[0] |
106 else: |
103 else: |
107 ioEncoding = Preferences.getSystem("IOEncoding") |
|
108 process = QProcess() |
104 process = QProcess() |
109 process.setWorkingDirectory(repodir) |
105 process.setWorkingDirectory(repodir) |
110 process.start('hg', args) |
106 process.start('hg', args) |
111 procStarted = process.waitForStarted(5000) |
107 procStarted = process.waitForStarted(5000) |
112 if procStarted: |
108 if procStarted: |
113 finished = process.waitForFinished(30000) |
109 finished = process.waitForFinished(30000) |
114 if finished and process.exitCode() == 0: |
110 if finished and process.exitCode() == 0: |
115 output = str( |
111 output = str(process.readAllStandardOutput(), |
116 process.readAllStandardOutput(), ioEncoding, 'replace') |
112 self.vcs.getEncoding(), 'replace') |
117 |
113 |
118 for line in output.splitlines(): |
114 for line in output.splitlines(): |
119 if withSummary: |
115 if withSummary: |
120 li = line.strip().split(": ") |
116 li = line.strip().split(": ") |
121 if len(li) == 1: |
117 if len(li) == 1: |
135 @param repodir directory name of the repository (string) |
131 @param repodir directory name of the repository (string) |
136 @return name of the current patch (string) |
132 @return name of the current patch (string) |
137 """ |
133 """ |
138 currentPatch = "" |
134 currentPatch = "" |
139 |
135 |
140 args = [] |
136 args = self.vcs.initCommand("qtop") |
141 args.append("qtop") |
|
142 |
137 |
143 client = self.vcs.getClient() |
138 client = self.vcs.getClient() |
144 if client: |
139 if client: |
145 currentPatch = client.runcommand(args)[0].strip() |
140 currentPatch = client.runcommand(args)[0].strip() |
146 else: |
141 else: |
147 ioEncoding = Preferences.getSystem("IOEncoding") |
|
148 process = QProcess() |
142 process = QProcess() |
149 process.setWorkingDirectory(repodir) |
143 process.setWorkingDirectory(repodir) |
150 process.start('hg', args) |
144 process.start('hg', args) |
151 procStarted = process.waitForStarted(5000) |
145 procStarted = process.waitForStarted(5000) |
152 if procStarted: |
146 if procStarted: |
153 finished = process.waitForFinished(30000) |
147 finished = process.waitForFinished(30000) |
154 if finished and process.exitCode() == 0: |
148 if finished and process.exitCode() == 0: |
155 currentPatch = str( |
149 currentPatch = str(process.readAllStandardOutput(), |
156 process.readAllStandardOutput(), |
150 self.vcs.getEncoding(), |
157 ioEncoding, 'replace').strip() |
151 'replace').strip() |
158 |
152 |
159 return currentPatch |
153 return currentPatch |
160 |
154 |
161 def __getCommitMessage(self, repodir): |
155 def __getCommitMessage(self, repodir): |
162 """ |
156 """ |
165 @param repodir directory name of the repository (string) |
159 @param repodir directory name of the repository (string) |
166 @return name of the current patch (string) |
160 @return name of the current patch (string) |
167 """ |
161 """ |
168 message = "" |
162 message = "" |
169 |
163 |
170 args = [] |
164 args = self.vcs.initCommand("qheader") |
171 args.append("qheader") |
|
172 |
165 |
173 client = self.vcs.getClient() |
166 client = self.vcs.getClient() |
174 if client: |
167 if client: |
175 message = client.runcommand(args)[0] |
168 message = client.runcommand(args)[0] |
176 else: |
169 else: |
177 ioEncoding = Preferences.getSystem("IOEncoding") |
|
178 process = QProcess() |
170 process = QProcess() |
179 process.setWorkingDirectory(repodir) |
171 process.setWorkingDirectory(repodir) |
180 process.start('hg', args) |
172 process.start('hg', args) |
181 procStarted = process.waitForStarted(5000) |
173 procStarted = process.waitForStarted(5000) |
182 if procStarted: |
174 if procStarted: |
183 finished = process.waitForFinished(30000) |
175 finished = process.waitForFinished(30000) |
184 if finished and process.exitCode() == 0: |
176 if finished and process.exitCode() == 0: |
185 message = str( |
177 message = str(process.readAllStandardOutput(), |
186 process.readAllStandardOutput(), |
178 self.vcs.getEncoding(), 'replace') |
187 ioEncoding, 'replace') |
|
188 |
179 |
189 return message |
180 return message |
190 |
181 |
191 def getGuardsList(self, repodir, all=True): |
182 def getGuardsList(self, repodir, all=True): |
192 """ |
183 """ |
196 @param all flag indicating to get all guards (boolean) |
187 @param all flag indicating to get all guards (boolean) |
197 @return sorted list of guards (list of strings) |
188 @return sorted list of guards (list of strings) |
198 """ |
189 """ |
199 guardsList = [] |
190 guardsList = [] |
200 |
191 |
201 args = [] |
192 args = self.vcs.initCommand("qselect") |
202 args.append("qselect") |
|
203 if all: |
193 if all: |
204 args.append("--series") |
194 args.append("--series") |
205 |
195 |
206 client = self.vcs.getClient() |
196 client = self.vcs.getClient() |
207 output = "" |
197 output = "" |
208 if client: |
198 if client: |
209 output = client.runcommand(args)[0] |
199 output = client.runcommand(args)[0] |
210 else: |
200 else: |
211 ioEncoding = Preferences.getSystem("IOEncoding") |
|
212 process = QProcess() |
201 process = QProcess() |
213 process.setWorkingDirectory(repodir) |
202 process.setWorkingDirectory(repodir) |
214 process.start('hg', args) |
203 process.start('hg', args) |
215 procStarted = process.waitForStarted(5000) |
204 procStarted = process.waitForStarted(5000) |
216 if procStarted: |
205 if procStarted: |
217 finished = process.waitForFinished(30000) |
206 finished = process.waitForFinished(30000) |
218 if finished and process.exitCode() == 0: |
207 if finished and process.exitCode() == 0: |
219 output = str( |
208 output = str(process.readAllStandardOutput(), |
220 process.readAllStandardOutput(), ioEncoding, 'replace') |
209 self.vcs.getEncoding(), 'replace') |
221 |
210 |
222 for guard in output.splitlines(): |
211 for guard in output.splitlines(): |
223 guard = guard.strip() |
212 guard = guard.strip() |
224 if all: |
213 if all: |
225 guard = guard[1:] |
214 guard = guard[1:] |
245 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.NEW_MODE) |
234 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.NEW_MODE) |
246 if dlg.exec_() == QDialog.Accepted: |
235 if dlg.exec_() == QDialog.Accepted: |
247 name, message, (userData, currentUser, userName), \ |
236 name, message, (userData, currentUser, userName), \ |
248 (dateData, currentDate, dateStr) = dlg.getData() |
237 (dateData, currentDate, dateStr) = dlg.getData() |
249 |
238 |
250 args = [] |
239 args = self.vcs.initCommand("qnew") |
251 args.append("qnew") |
|
252 if message != "": |
240 if message != "": |
253 args.append("--message") |
241 args.append("--message") |
254 args.append(message) |
242 args.append(message) |
255 if userData: |
243 if userData: |
256 if currentUser: |
244 if currentUser: |
285 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
273 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
286 repodir = os.path.dirname(repodir) |
274 repodir = os.path.dirname(repodir) |
287 if os.path.splitdrive(repodir)[1] == os.sep: |
275 if os.path.splitdrive(repodir)[1] == os.sep: |
288 return |
276 return |
289 |
277 |
290 args = [] |
278 args = self.vcs.initCommand("qrefresh") |
291 args.append("qrefresh") |
|
292 |
279 |
293 if editMessage: |
280 if editMessage: |
294 currentMessage = self.__getCommitMessage(repodir) |
281 currentMessage = self.__getCommitMessage(repodir) |
295 from .HgQueuesNewPatchDialog import HgQueuesNewPatchDialog |
282 from .HgQueuesNewPatchDialog import HgQueuesNewPatchDialog |
296 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.REFRESH_MODE, |
283 dlg = HgQueuesNewPatchDialog(HgQueuesNewPatchDialog.REFRESH_MODE, |
367 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
354 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
368 repodir = os.path.dirname(repodir) |
355 repodir = os.path.dirname(repodir) |
369 if os.path.splitdrive(repodir)[1] == os.sep: |
356 if os.path.splitdrive(repodir)[1] == os.sep: |
370 return False |
357 return False |
371 |
358 |
372 args = [] |
|
373 if operation == Queues.POP: |
359 if operation == Queues.POP: |
374 args.append("qpop") |
360 args = self.vcs.initCommand("qpop") |
375 title = self.tr("Pop Patches") |
361 title = self.tr("Pop Patches") |
376 listType = Queues.APPLIED_LIST |
362 listType = Queues.APPLIED_LIST |
377 elif operation == Queues.PUSH: |
363 elif operation == Queues.PUSH: |
378 args.append("qpush") |
364 args = self.vcs.initCommand("qpush") |
379 title = self.tr("Push Patches") |
365 title = self.tr("Push Patches") |
380 listType = Queues.UNAPPLIED_LIST |
366 listType = Queues.UNAPPLIED_LIST |
381 elif operation == Queues.GOTO: |
367 elif operation == Queues.GOTO: |
382 args.append("qgoto") |
368 args = self.vcs.initCommand("qgoto") |
383 title = self.tr("Go to Patch") |
369 title = self.tr("Go to Patch") |
384 listType = Queues.SERIES_LIST |
370 listType = Queues.SERIES_LIST |
385 else: |
371 else: |
386 raise ValueError("illegal value for operation") |
372 raise ValueError("illegal value for operation") |
387 args.append("-v") |
373 args.append("-v") |
439 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
425 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
440 repodir = os.path.dirname(repodir) |
426 repodir = os.path.dirname(repodir) |
441 if os.path.splitdrive(repodir)[1] == os.sep: |
427 if os.path.splitdrive(repodir)[1] == os.sep: |
442 return |
428 return |
443 |
429 |
444 args = [] |
430 args = self.vcs.initCommand("qfinish") |
445 args.append("qfinish") |
|
446 args.append("--applied") |
431 args.append("--applied") |
447 |
432 |
448 dia = HgDialog(self.tr('Finish Applied Patches'), self.vcs) |
433 dia = HgDialog(self.tr('Finish Applied Patches'), self.vcs) |
449 res = dia.startProcess(args, repodir) |
434 res = dia.startProcess(args, repodir) |
450 if res: |
435 if res: |
462 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
447 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
463 repodir = os.path.dirname(repodir) |
448 repodir = os.path.dirname(repodir) |
464 if os.path.splitdrive(repodir)[1] == os.sep: |
449 if os.path.splitdrive(repodir)[1] == os.sep: |
465 return |
450 return |
466 |
451 |
467 args = [] |
452 args = self.vcs.initCommand("qrename") |
468 args.append("qrename") |
|
469 patchnames = sorted(self.__getPatchesList(repodir, Queues.SERIES_LIST)) |
453 patchnames = sorted(self.__getPatchesList(repodir, Queues.SERIES_LIST)) |
470 if patchnames: |
454 if patchnames: |
471 currentPatch = self.__getCurrentPatch(repodir) |
455 currentPatch = self.__getCurrentPatch(repodir) |
472 if currentPatch: |
456 if currentPatch: |
473 from .HgQueuesRenamePatchDialog import \ |
457 from .HgQueuesRenamePatchDialog import \ |
495 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
479 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
496 repodir = os.path.dirname(repodir) |
480 repodir = os.path.dirname(repodir) |
497 if os.path.splitdrive(repodir)[1] == os.sep: |
481 if os.path.splitdrive(repodir)[1] == os.sep: |
498 return |
482 return |
499 |
483 |
500 args = [] |
484 args = self.vcs.initCommand("qdelete") |
501 args.append("qdelete") |
|
502 patchnames = sorted(self.__getPatchesList(repodir, |
485 patchnames = sorted(self.__getPatchesList(repodir, |
503 Queues.UNAPPLIED_LIST)) |
486 Queues.UNAPPLIED_LIST)) |
504 if patchnames: |
487 if patchnames: |
505 patch, ok = QInputDialog.getItem( |
488 patch, ok = QInputDialog.getItem( |
506 None, |
489 None, |
532 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
515 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
533 repodir = os.path.dirname(repodir) |
516 repodir = os.path.dirname(repodir) |
534 if os.path.splitdrive(repodir)[1] == os.sep: |
517 if os.path.splitdrive(repodir)[1] == os.sep: |
535 return |
518 return |
536 |
519 |
537 args = [] |
520 args = self.vcs.initCommand("qfold") |
538 args.append("qfold") |
|
539 patchnames = sorted( |
521 patchnames = sorted( |
540 self.__getPatchesList(repodir, Queues.UNAPPLIED_LIST, |
522 self.__getPatchesList(repodir, Queues.UNAPPLIED_LIST, |
541 withSummary=True)) |
523 withSummary=True)) |
542 if patchnames: |
524 if patchnames: |
543 from .HgQueuesFoldDialog import HgQueuesFoldDialog |
525 from .HgQueuesFoldDialog import HgQueuesFoldDialog |
652 self.tr("Select the patch to drop guards for" |
634 self.tr("Select the patch to drop guards for" |
653 " (leave empty for the current patch):"), |
635 " (leave empty for the current patch):"), |
654 [""] + patchnames, |
636 [""] + patchnames, |
655 0, False) |
637 0, False) |
656 if ok: |
638 if ok: |
657 args = [] |
639 args = self.vcs.initCommand("qguard") |
658 args.append("qguard") |
|
659 if patch: |
640 if patch: |
660 args.append(patch) |
641 args.append(patch) |
661 args.append("--none") |
642 args.append("--none") |
662 |
643 |
663 client = self.vcs.getClient() |
644 client = self.vcs.getClient() |
697 dlg = HgQueuesGuardsSelectionDialog( |
678 dlg = HgQueuesGuardsSelectionDialog( |
698 guardsList, activeGuards=activeGuardsList, listOnly=False) |
679 guardsList, activeGuards=activeGuardsList, listOnly=False) |
699 if dlg.exec_() == QDialog.Accepted: |
680 if dlg.exec_() == QDialog.Accepted: |
700 guards = dlg.getData() |
681 guards = dlg.getData() |
701 if guards: |
682 if guards: |
702 args = [] |
683 args = self.vcs.initCommand("qselect") |
703 args.append("qselect") |
|
704 args.extend(guards) |
684 args.extend(guards) |
705 |
685 |
706 dia = HgDialog(self.tr('Set Active Guards'), self.vcs) |
686 dia = HgDialog(self.tr('Set Active Guards'), self.vcs) |
707 res = dia.startProcess(args, repodir) |
687 res = dia.startProcess(args, repodir) |
708 if res: |
688 if res: |
725 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
705 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
726 repodir = os.path.dirname(repodir) |
706 repodir = os.path.dirname(repodir) |
727 if os.path.splitdrive(repodir)[1] == os.sep: |
707 if os.path.splitdrive(repodir)[1] == os.sep: |
728 return |
708 return |
729 |
709 |
730 args = [] |
710 args = self.vcs.initCommand("qselect") |
731 args.append("qselect") |
|
732 args.append("--none") |
711 args.append("--none") |
733 |
712 |
734 dia = HgDialog(self.tr('Deactivate Guards'), self.vcs) |
713 dia = HgDialog(self.tr('Deactivate Guards'), self.vcs) |
735 res = dia.startProcess(args, repodir) |
714 res = dia.startProcess(args, repodir) |
736 if res: |
715 if res: |
780 HgQueuesQueueManagementDialog.NAME_INPUT, |
759 HgQueuesQueueManagementDialog.NAME_INPUT, |
781 title, False, repodir, self.vcs) |
760 title, False, repodir, self.vcs) |
782 if dlg.exec_() == QDialog.Accepted: |
761 if dlg.exec_() == QDialog.Accepted: |
783 queueName = dlg.getData() |
762 queueName = dlg.getData() |
784 if queueName: |
763 if queueName: |
785 args = [] |
764 args = self.vcs.initCommand("qqueue") |
786 args.append("qqueue") |
|
787 if isCreate: |
765 if isCreate: |
788 args.append("--create") |
766 args.append("--create") |
789 else: |
767 else: |
790 args.append("--rename") |
768 args.append("--rename") |
791 args.append(queueName) |
769 args.append(queueName) |
793 client = self.vcs.getClient() |
771 client = self.vcs.getClient() |
794 error = "" |
772 error = "" |
795 if client: |
773 if client: |
796 error = client.runcommand(args)[1] |
774 error = client.runcommand(args)[1] |
797 else: |
775 else: |
798 ioEncoding = Preferences.getSystem("IOEncoding") |
|
799 process = QProcess() |
776 process = QProcess() |
800 process.setWorkingDirectory(repodir) |
777 process.setWorkingDirectory(repodir) |
801 process.start('hg', args) |
778 process.start('hg', args) |
802 procStarted = process.waitForStarted(5000) |
779 procStarted = process.waitForStarted(5000) |
803 if procStarted: |
780 if procStarted: |
804 finished = process.waitForFinished(30000) |
781 finished = process.waitForFinished(30000) |
805 if finished: |
782 if finished: |
806 if process.exitCode() != 0: |
783 if process.exitCode() != 0: |
807 error = \ |
784 error = str(process.readAllStandardError(), |
808 str(process.readAllStandardError(), |
785 self.vcs.getEncoding(), 'replace') |
809 ioEncoding, 'replace') |
|
810 |
786 |
811 if error: |
787 if error: |
812 if isCreate: |
788 if isCreate: |
813 errMsg = self.tr( |
789 errMsg = self.tr( |
814 "Error while creating a new queue.") |
790 "Error while creating a new queue.") |
856 HgQueuesQueueManagementDialog.QUEUE_INPUT, |
832 HgQueuesQueueManagementDialog.QUEUE_INPUT, |
857 title, True, repodir, self.vcs) |
833 title, True, repodir, self.vcs) |
858 if dlg.exec_() == QDialog.Accepted: |
834 if dlg.exec_() == QDialog.Accepted: |
859 queueName = dlg.getData() |
835 queueName = dlg.getData() |
860 if queueName: |
836 if queueName: |
861 args = [] |
837 args = self.vcs.initCommand("qqueue") |
862 args.append("qqueue") |
|
863 if operation == Queues.QUEUE_PURGE: |
838 if operation == Queues.QUEUE_PURGE: |
864 args.append("--purge") |
839 args.append("--purge") |
865 elif operation == Queues.QUEUE_DELETE: |
840 elif operation == Queues.QUEUE_DELETE: |
866 args.append("--delete") |
841 args.append("--delete") |
867 args.append(queueName) |
842 args.append(queueName) |
869 client = self.vcs.getClient() |
844 client = self.vcs.getClient() |
870 error = "" |
845 error = "" |
871 if client: |
846 if client: |
872 error = client.runcommand(args)[1] |
847 error = client.runcommand(args)[1] |
873 else: |
848 else: |
874 ioEncoding = Preferences.getSystem("IOEncoding") |
|
875 process = QProcess() |
849 process = QProcess() |
876 process.setWorkingDirectory(repodir) |
850 process.setWorkingDirectory(repodir) |
877 process.start('hg', args) |
851 process.start('hg', args) |
878 procStarted = process.waitForStarted(5000) |
852 procStarted = process.waitForStarted(5000) |
879 if procStarted: |
853 if procStarted: |
880 finished = process.waitForFinished(30000) |
854 finished = process.waitForFinished(30000) |
881 if finished: |
855 if finished: |
882 if process.exitCode() != 0: |
856 if process.exitCode() != 0: |
883 error = \ |
857 error = str(process.readAllStandardError(), |
884 str(process.readAllStandardError(), |
858 self.vcs.getEncoding(), 'replace') |
885 ioEncoding, 'replace') |
|
886 |
859 |
887 if error: |
860 if error: |
888 if operation == Queues.QUEUE_PURGE: |
861 if operation == Queues.QUEUE_PURGE: |
889 errMsg = self.tr("Error while purging the queue.") |
862 errMsg = self.tr("Error while purging the queue.") |
890 elif operation == Queues.QUEUE_DELETE: |
863 elif operation == Queues.QUEUE_DELETE: |
933 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
906 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
934 repodir = os.path.dirname(repodir) |
907 repodir = os.path.dirname(repodir) |
935 if os.path.splitdrive(repodir)[1] == os.sep: |
908 if os.path.splitdrive(repodir)[1] == os.sep: |
936 return |
909 return |
937 |
910 |
938 args = [] |
911 args = self.vcs.initCommand("init") |
939 args.append('init') |
|
940 args.append('--mq') |
912 args.append('--mq') |
941 args.append(repodir) |
913 args.append(repodir) |
942 # init is not possible with the command server |
914 # init is not possible with the command server |
943 dia = HgDialog( |
915 dia = HgDialog( |
944 self.tr('Initializing new queue repository'), self.vcs) |
916 self.tr('Initializing new queue repository'), self.vcs) |