Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0, 2.0.1, and 2.0.2

stable mq: maintain patch and file selections through refresh

Check state refresh can be improved in the next release

Changeset 73a49ac20aeb

Parent 9300eaab0985

by Steve Borho

Changes to one file · Browse files at 73a49ac20aeb Showing diff from parent 9300eaab0985 Diff from another changeset...

 
20
21
22
 
 
 
 
 
23
24
25
 
523
524
525
 
526
527
528
 
533
534
535
 
 
 
536
537
538
539
540
541
542
543
544
 
551
552
553
554
 
 
 
 
 
 
 
555
556
557
 
580
581
582
 
583
584
 
 
585
586
587
 
628
629
630
631
632
633
634
 
657
658
659
 
 
660
 
661
662
663
 
664
665
666
667
668
669
 
 
670
671
672
 
673
674
675
676
677
678
 
 
 
 
 
 
 
679
680
681
 
20
21
22
23
24
25
26
27
28
29
30
 
528
529
530
531
532
533
534
 
539
540
541
542
543
544
545
546
547
548
549
 
550
551
552
 
559
560
561
 
562
563
564
565
566
567
568
569
570
571
 
594
595
596
597
598
599
600
601
602
603
604
 
645
646
647
 
648
649
650
 
673
674
675
676
677
678
679
680
681
 
682
683
684
685
686
687
688
689
690
691
 
 
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
@@ -20,6 +20,11 @@
 from tortoisehg.hgqt import qtlib, cmdui, rejects, commit, qscilib  from tortoisehg.hgqt import qqueue, fileview   +# TODO +# keep original file name in file list item +# maintain check state through refresh +# more wctx functions +  class MQWidget(QWidget):   showMessage = pyqtSignal(unicode)   output = pyqtSignal(QString, QString) @@ -523,6 +528,7 @@
    def reload(self):   self.refreshing = True + self.reselectPatchItem = None   try:   try:   self._reload() @@ -533,12 +539,14 @@
  traceback.print_exc()   finally:   self.refreshing = False + if self.reselectPatchItem: + self.queueListWidget.setCurrentItem(self.reselectPatchItem) + self.refreshFileListWidget()     def _reload(self):   ui, repo = self.repo.ui.copy(), self.repo     self.queueCombo.clear() - self.queueListWidget.clear()     ui.quiet = True # don't append "(active)"   ui.pushbuffer() @@ -551,7 +559,13 @@
  self.queueCombo.setCurrentIndex(current)   self.queueCombo.setEnabled(self.queueCombo.count() > 1)   - # TODO: maintain current selection + item = self.queueListWidget.currentItem() + if item: + wasselected = item._thgpatch + else: + wasselected = None + self.queueListWidget.clear() +   applied = set([p.name for p in repo.mq.applied])   self.allguards = set()   items = [] @@ -580,8 +594,11 @@
  Qt.ItemIsEditable |   Qt.ItemIsEnabled)   items.append(item) +   for item in reversed(items):   self.queueListWidget.addItem(item) + if item._thgpatch == wasselected: + self.reselectPatchItem = item     for guard in repo.mq.active():   self.allguards.add(guard) @@ -628,7 +645,6 @@
  self.setMessage('')   self.patchNameLE.setText('')   self.patchNameLE.setEnabled(newmode) - self.refreshFileListWidget()     def onNewModeToggled(self, isChecked):   if isChecked: @@ -657,25 +673,36 @@
  self.patchNameLE.setText('')   self.setMessage('')   self.patchNameLE.setEnabled(False) + + def refreshFileListWidget(self):   self.refreshing = True + self.reselectFileItem = None   try:   try: - self.refreshFileListWidget() + self._refreshFileListWidget()   except Exception, e:   self.showMessage.emit(hglib.tounicode(str(e)))   import traceback   traceback.print_exc()   finally:   self.refreshing = False + if self.reselectFileItem: + self.fileListWidget.setCurrentItem(self.reselectFileItem)   - def refreshFileListWidget(self): - # TODO: maintain selection, check state + def _refreshFileListWidget(self):   def addfiles(mode, files, initial):   for file in files:   item = QListWidgetItem(u'%s %s' % (mode, hglib.tounicode(file)))   item.setFlags(flags)   item.setCheckState(initial)   self.fileListWidget.addItem(item) + if selfile == file: + self.reselectFileItem = item + item = self.fileListWidget.currentItem() + if item: + selfile = hglib.fromunicode(item.text())[2:] + else: + selfile = None   self.fileListWidget.clear()   self.fileview.clearDisplay()   pctx = self.repo.changectx('.')