Commits

Andrea Stagi committed f9a97e7

Close the relative tab when repository is removed from registry

Comments (0)

Files changed (2)

tortoisehg/hgqt/reporegistry.py

 
     showMessage = pyqtSignal(QString)
     openRepo = pyqtSignal(QString, bool)
+    removeRepo = pyqtSignal(QString)
 
     def __init__(self, parent, showSubrepos=False, showNetworkSubrepos=False,
             showShortPaths=False):
         m.removeRows(row, 1, parent)
         self.tview.selectionChanged(None, None)
         self.updateSettingsFile()
+        root = s.internalPointer().rootpath()
+        root = hglib.tounicode(root)
+        self.removeRepo.emit(root)
 
     @pyqtSlot(QString, QString)
     def shortNameChanged(self, uroot, uname):

tortoisehg/hgqt/workbench.py

         rr.setObjectName('RepoRegistryView')
         rr.showMessage.connect(self.showMessage)
         rr.openRepo.connect(self.openRepo)
+        rr.removeRepo.connect(self.removeRepo)
         rr.hide()
         self.addDockWidget(Qt.LeftDockWidgetArea, rr)
         self.activeRepoChanged.connect(rr.setActiveTabRepo)
         root = hglib.fromunicode(root)
         self._openRepo(root, reuse)
 
+    def removeRepo(self, root):
+        """ Close tab if the repo is removed from reporegistry [unicode] """
+        root = hglib.fromunicode(root)
+        for i in xrange(self.repoTabsWidget.count()):
+             w = self.repoTabsWidget.widget(i)
+             if hglib.tounicode(w.repo.root) == os.path.normpath(root):
+                 self.repoTabCloseRequested(i)
+                 return
+
     @pyqtSlot(QString)
     def openLinkedRepo(self, path):
         self.showRepo(path)