Commits

Steve Borho  committed 23dcd48 Merge

Merge with stable

  • Participants
  • Parent commits 6812fed, 19892fa

Comments (0)

Files changed (5)

File tortoisehg/hgqt/customtools.py

         topvbox.addWidget(QLabel(_('Select a GUI location to edit:')))
 
         self.locationcombo = QComboBox(self,
-            toolTip='Select the toolbar or menu to change')
+            toolTip=_('Select the toolbar or menu to change'))
 
         def selectlocation(index):
             location = self.locationcombo.itemText(index)
         QDialog.__init__(self, parent)
 
         self.setWindowIcon(qtlib.geticon('tools-spanner-hammer'))
-        self.setWindowTitle('Configure Custom Tool')
+        self.setWindowTitle(_('Configure Custom Tool'))
         self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
 
         self.hbox = QHBoxLayout()

File tortoisehg/hgqt/filedialogs.py

         super(FileLogDialog, self).__init__(repo, filename, repoviewer)
         self._readSettings()
         self.menu = None
+        self.dualmenu = None
 
     def closeEvent(self, event):
         self._writeSettings()
         self.setCentralWidget(self.splitter)
         cs = ('fileLogDialog', _('File History Log Columns'))
         self.repoview = repoview.HgRepoView(self.repo, cs[0], cs, self.splitter)
-        self.repoview.setSelectionMode(QAbstractItemView.SingleSelection)
+
+        # It does not make sense to select more than two revisions at a time.
+        # Rather than enforcing a max selection size we simply let the user
+        # know when it has selected too many revisions by using the status bar
+        def checkValidSelection(selected, deselected):
+            selection = self.repoview.selectedRevisions()
+            if len(selection) > 2:
+                msg = _('Too many rows selected for menu')
+            else:
+                msg = ''
+            self.textView.showMessage.emit(msg)
+        self.repoview.revisionSelectionChanged.connect(checkValidSelection)
+
         self.contentframe = QFrame(self.splitter)
 
         vbox = QVBoxLayout()
     @pyqtSlot(QPoint, object)
     def viewMenuRequest(self, point, selection):
         'User requested a context menu in repo view widget'
-        if not selection:
+        if not selection or len(selection) > 2:
             return
-        if self.menu is None:
+        if len(selection) == 2:
+            if self.dualmenu is None:
+                self.dualmenu = menu = QMenu(self)
+                a = menu.addAction(_('Diff selected changesets...'))
+                a.triggered.connect(self.onVisualDiffRevs)
+                a = menu.addAction(_('Diff selected file revisions...'))
+                a.setIcon(qtlib.getmenuicon('visualdiff'))
+                a.triggered.connect(self.onVisualDiffFileRevs)
+            else:
+                menu = self.dualmenu
+        elif self.menu is None:
             self.menu = menu = QMenu(self)
             a = menu.addAction(_('Diff changeset to parent...'))
             a.setIcon(qtlib.getmenuicon('visualdiff'))
             a = menu.addAction(_('Revert to revision...'))
             a.setIcon(qtlib.getmenuicon('hg-revert'))
             a.triggered.connect(self.onRevertFileToRevision)
+        else:
+            menu = self.menu
         self.selection = selection
-        self.menu.exec_(point)
+        menu.exec_(point)
 
     def onVisualDiff(self):
         opts = dict(change=self.selection[0])
             dlg.exec_()
             dlg.deleteLater()
 
+    def onVisualDiffRevs(self):
+        revs = self.selection
+        if len(revs) != 2:
+            self.textView.showMessage.emit(_('You must select two revisions to diff'))
+            return
+        opts = dict(rev=revs)
+        dlg = visdiff.visualdiff(self.repo.ui, self.repo, [], opts)
+        if dlg:
+            dlg.exec_()
+            dlg.deleteLater()
+
     def onVisualDiffFile(self):
         rev = self.selection[0]
         paths = [self.filerevmodel.graph.filename(rev)]
             dlg.exec_()
             dlg.deleteLater()
 
+    def onVisualDiffFileRevs(self):
+        revs = self.selection
+        if len(revs) != 2:
+            self.textView.showMessage.emit(_('You must select two revisions to diff'))
+            return
+        paths = [self.filerevmodel.graph.filename(revs[0])]
+        opts = dict(rev=['rev(%d)' % rev for rev in revs])
+        dlg = visdiff.visualdiff(self.repo.ui, self.repo, paths, opts)
+        if dlg:
+            dlg.exec_()
+            dlg.deleteLater()
+
     def onEditLocal(self):
         filenames = [self.filename]
         if not filenames:
         self.setCentralWidget(self.splitter)
         self.horizontalLayout = QHBoxLayout()
         cs = ('fileDiffDialogLeft', _('File Differences Log Columns'))
-        self.fileHistoryLeft = repoview.HgRepoView(self.repo, cs[0],
+        self.tableView_revisions_left = repoview.HgRepoView(self.repo, cs[0],
                                                             cs, self)
-        self.fileHistoryRight = repoview.HgRepoView(self.repo,
+        self.tableView_revisions_right = repoview.HgRepoView(self.repo,
                                                              'fileDiffDialogRight',
                                                              cs, self)
-        self.horizontalLayout.addWidget(self.fileHistoryLeft)
-        self.horizontalLayout.addWidget(self.fileHistoryRight)
-        self.fileHistoryRight.setSelectionMode(QAbstractItemView.SingleSelection)
-        self.fileHistoryLeft.setSelectionMode(QAbstractItemView.SingleSelection)
+        self.horizontalLayout.addWidget(self.tableView_revisions_left)
+        self.horizontalLayout.addWidget(self.tableView_revisions_right)
+        self.tableView_revisions_right.setSelectionMode(QAbstractItemView.SingleSelection)
+        self.tableView_revisions_left.setSelectionMode(QAbstractItemView.SingleSelection)
         self.frame = QFrame()
         self.splitter.addWidget(layouttowidget(self.horizontalLayout))
         self.splitter.addWidget(self.frame)
         menu.exec_(point)
 
     def setupViews(self):
-        self.tableViews = {'left': self.fileHistoryLeft,
-                           'right': self.fileHistoryRight}
+        self.tableViews = {'left': self.tableView_revisions_left,
+                           'right': self.tableView_revisions_right}
         # viewers are Scintilla editors
         self.viewers = {}
         # block are diff-block displayers
         self.filedata = {'left': None, 'right': None}
         self._invbarchanged = False
         self.filerevmodel = filerevmodel.FileRevModel(self.repo,
-                                         self.fileHistoryLeft.colselect[0],
+                                         self.tableView_revisions_left.colselect[0],
                                          self.filename, parent=self)
         self.filerevmodel.filled.connect(self.modelFilled)
-        self.fileHistoryLeft.setModel(self.filerevmodel)
-        self.fileHistoryRight.setModel(self.filerevmodel)
-        self.fileHistoryLeft.menuRequested.connect(self.viewMenuRequest)
-        self.fileHistoryRight.menuRequested.connect(self.viewMenuRequest)
+        self.tableView_revisions_left.setModel(self.filerevmodel)
+        self.tableView_revisions_right.setModel(self.filerevmodel)
+        self.tableView_revisions_left.menuRequested.connect(self.viewMenuRequest)
+        self.tableView_revisions_right.menuRequested.connect(self.viewMenuRequest)
 
     def createActions(self):
         self.actionClose.triggered.connect(self.close)
         self.editToolbar.addAction(self.actionPrevDiff)
 
     def modelFilled(self):
-        self.fileHistoryLeft.resizeColumns()
-        self.fileHistoryRight.resizeColumns()
+        self.tableView_revisions_left.resizeColumns()
+        self.tableView_revisions_right.resizeColumns()
         if self._show_rev is not None:
             self.goto(self._show_rev)
             self._show_rev = None
     def onRevisionSelected(self, rev):
         if rev is None or rev not in self.filerevmodel.graph.nodesdict:
             return
-        if self.sender() is self.fileHistoryRight:
+        if self.sender() is self.tableView_revisions_right:
             side = 'right'
         else:
             side = 'left'
         if index is not None:
             if index.row() == 0:
                 index = self.filerevmodel.index(1, 0)
-            self.fileHistoryLeft.setCurrentIndex(index)
+            self.tableView_revisions_left.setCurrentIndex(index)
             index = self.filerevmodel.index(0, 0)
-            self.fileHistoryRight.setCurrentIndex(index)
+            self.tableView_revisions_right.setCurrentIndex(index)
         else:
             self._show_rev = rev
 
         self._invbarchanged = False
 
     def reload(self):
-        self.fileHistoryLeft.saveSettings()
-        self.fileHistoryRight.saveSettings()
+        self.tableView_revisions_left.saveSettings()
+        self.tableView_revisions_right.saveSettings()
         super(FileDiffDialog, self).reload()
 
     @pyqtSlot(QPoint, object)

File tortoisehg/hgqt/fileview.py

 
     @pyqtSlot()
     def abort(self):
-        if self._threadid is None:
+        threadid = self._threadid
+        if threadid is None:
             return
         try:
-            thread2._async_raise(self._threadid, KeyboardInterrupt)
+            thread2._async_raise(threadid, KeyboardInterrupt)
             self.wait()
         except ValueError:
             pass

File tortoisehg/hgqt/repoview.py

     revisionAltClicked = pyqtSignal(object)
     revisionSelected = pyqtSignal(object)
     revisionActivated = pyqtSignal(object)
+    revisionSelectionChanged = pyqtSignal(QItemSelection, QItemSelection)
     menuRequested = pyqtSignal(QPoint, object)
     showMessage = pyqtSignal(unicode)
 
         if not QFontMetrics(self.font()).inFont(QString(u'\u2327').at(0)):
             model.unicodexinabox = False
         self.selectionModel().currentRowChanged.connect(self.onRowChange)
+        self.selectionModel().selectionChanged.connect(self.revisionSelectionChanged)
         self.resetDelegate()
         self._rev_history = []
         self._rev_pos = -1

File tortoisehg/hgqt/repowidget.py

             if os.path.exists(self.repo.sjoin('undo')):
                 try:
                     args = self.repo.opener('undo.desc', 'r').read().splitlines()
-                    if args[1] != 'commit':
-                        return None
                     return args[1], int(args[0])
                 except (IOError, IndexError, ValueError):
                     pass