Commits

Yuya Nishihara  committed a6434bb

workbench: eliminate signal chain by simply updating shortname on config changed

  • Participants
  • Parent commits 8346e19

Comments (0)

Files changed (3)

File tortoisehg/hgqt/reporegistry.py

                 return 0
         self.tview.model().sortchilds(ip.childs, keyfunc)
 
-    @pyqtSlot(QString, QString)
-    def shortNameChanged(self, uroot, uname):
+    def setShortName(self, uroot, uname):
         it = self.tview.model().getRepoItem(hglib.fromunicode(uroot))
         if it:
             it.setShortName(uname)

File tortoisehg/hgqt/repowidget.py

     # The following signals should be exchanged directly between workbench and
     # thgrepo. But it isn't possible because workbench cannot filter out known
     # repo from the result of thgrepo.repository().
-    shortNameChanged = pyqtSignal(QString, QString)
     baseNodeChanged = pyqtSignal(QString, object)
 
     revisionSelected = pyqtSignal(object)
         self.busyIcons = []
         self.namedTabs = {}
         self.repolen = len(repo)
-        self.shortname = None
         self.basenode = None
         self.destroyed.connect(self.repo.thginvalidate)
 
         'initial batch of revisions loaded'
         self.repoview.goto(self._reload_rev) # emits revisionSelected
         self.repoview.resizeColumns()
-        if self.repo.shortname != self.shortname:
-            self.shortname = self.repo.shortname
-            self.shortNameChanged.emit(hglib.tounicode(self.repo.root),
-                                       self.shortname)
         if len(self.repo) and self.repo[0].node() != self.basenode:
             self.basenode = self.repo[0].node()
             self.baseNodeChanged.emit(hglib.tounicode(self.repo.root),
         self.revDetailsWidget.reload()
         self.titleChanged.emit(self.title())
         self.updateTaskTabs()
-        if self.repo.shortname != self.shortname:
-            self.shortname = self.repo.shortname
-            self.shortNameChanged.emit(hglib.tounicode(self.repo.root),
-                                       self.shortname)
 
     def updateTaskTabs(self):
         val = self.repo.ui.config('tortoisehg', 'tasktabs', 'off').lower()

File tortoisehg/hgqt/workbench.py

         self.ui = ui
         self._repomanager = repomanager
         self._repomanager.configChanged.connect(self._setupUrlComboIfCurrent)
+        self._repomanager.configChanged.connect(self._updateRepoShortName)
         self._repomanager.repositoryDestroyed.connect(self.closeRepo)
+        self._repomanager.repositoryOpened.connect(self._updateRepoRegItem)
 
         self.setupUi()
         self.setWindowTitle(_('TortoiseHg Workbench'))
         self.actionBack.setEnabled(rw.canGoBack())
         self.actionForward.setEnabled(rw.canGoForward())
 
+    # might be better to move them to RepoRegistry
+    @pyqtSlot(unicode)
+    def _updateRepoRegItem(self, root):
+        self._updateRepoShortName(root)
+
+    @pyqtSlot(unicode)
+    def _updateRepoShortName(self, root):
+        repo = self._repomanager.repoAgent(root).rawRepo()
+        self.reporegistry.setShortName(root, repo.shortname)
+
     @pyqtSlot(int)
     def repoTabCloseRequested(self, index):
         tw = self.repoTabsWidget
         rw.repoLinkClicked.connect(self.openLinkedRepo)
         rw.taskTabsWidget.currentChanged.connect(self.updateTaskViewMenu)
         rw.toolbarVisibilityChanged.connect(self.updateToolBarActions)
-        rw.shortNameChanged.connect(self.reporegistry.shortNameChanged)
         rw.baseNodeChanged.connect(self.reporegistry.baseNodeChanged)
 
         tw = self.repoTabsWidget