Commits

Angel Ezquerra committed 8e16e0f

filelistview: Add "Open subrepository" context menu action

This action tries to open the selected subrepository. If the subrepository does
not exist, it will display a warning message instead.

  • Participants
  • Parent commits ee3883c
  • Branches stable

Comments (0)

Files changed (2)

File tortoisehg/hgqt/filelistview.py

 
     fileRevSelected = pyqtSignal(object, object, object)
     clearDisplay = pyqtSignal()
+    linkActivated = pyqtSignal(QString)
     filecontextmenu = None
     subrepocontextmenu = None
 
             ('revert', _('Revert to Revision'), 'hg-revert', 'Alt+Ctrl+T',
               _('Revert file(s) to contents at this revision'),
               self.revertfile),
+            ('opensubrepo', _('Open subrepository'), 'thg-repository-open', 
+              'Alt+Ctrl+O', _('Open the selected subrepository'),
+              self.opensubrepo),
             ]:
             act = QAction(desc, self)
             if icon:
                 act.triggered.connect(cb)
             self._actions[name] = act
             self.addAction(act)
-
+    
+    def opensubrepo(self):
+        path = os.path.join(self.model().repo.root, self.currentFile())
+        if os.path.isdir(path):
+            self.linkActivated.emit(u'subrepo:'+hglib.tounicode(path))
+        else:
+            QMessageBox.warning(self,
+                _("Cannot open subrepository"),
+                _("The selected subrepository does not exist on the working directory"))
+        
     def contextMenuEvent(self, event):
         itemissubrepo = (self.model().dataFromIndex(self.currentIndex())['status'] == 'S')
 
         # Subrepos and regular items have different context menus
         if itemissubrepo:
             contextmenu = self.subrepocontextmenu
-            actionlist = []
+            actionlist = ['opensubrepo']
         else:
             contextmenu = self.filecontextmenu
             actionlist = ['diff', 'ldiff', 'edit', 'ledit', 'revert',

File tortoisehg/hgqt/revdetails.py

         self.filelistToolbar = QToolBar(_('File List Toolbar'))
         self.filelistToolbar.setIconSize(QSize(16,16))
         self.filelist = HgFileListView()
+        self.filelist.linkActivated.connect(self.linkActivated)
 
         self.tbarFileListFrame = QFrame(self.filelist_splitter)
         sp = SP(SP.Preferred, SP.Preferred)