Commits

Yuya Nishihara committed d6f0937

repoagent: unify workingBranchChanged with repositoryChanged (fixes #2572)

Because of this change, the following models and widgets will notice the change
of the working branch. Some of them are not necessary, but they won't hurt:

- BackoutDialog, MergeDialog and stand-alone RevDetailsDialog should notice
the change of the working branch
- BookmarkDialog, ResolveDialog, ShelveDialog and TagDialog will refresh data
unnecessarily
- stand-alone CommitDialog will update "undo" button state unnecessarily
- PatchQueueModel and MQPatchesWidget will be modified later to listen only
to MQ changes
- RepoTreeModel (reporegistry) will update first-revision node unnecessarily
- RepoWidget should recreate HgRepoListModel (issue #2572)
- Workbench will trigger subrepo scan unnecessarily

  • Participants
  • Parent commits 84ef52f

Comments (0)

Files changed (4)

tests/qt_repoagent_test.py

         repo = thgrepo.repository(ui, self.hg.path)
         self.agent = agent = thgrepo.RepoAgent(repo)
         self.repositoryChanged = mock.Mock()
-        self.workingBranchChanged = mock.Mock()
         agent.repositoryChanged.connect(self.repositoryChanged)
-        agent.workingBranchChanged.connect(self.workingBranchChanged)
         agent.startMonitoringIfEnabled()
 
     def tearDown(self):
 
     def wait_changed(self, flags, timeout=5000):
         self.repositoryChanged.reset_mock()
-        self.workingBranchChanged.reset_mock()
         loop = QEventLoop()
         self.agent.repositoryChanged.connect(loop.quit)
-        self.agent.workingBranchChanged.connect(loop.quit)
         QTimer.singleShot(timeout, loop.quit)
         loop.exec_()
-        if flags & (thgrepo.LogChanged | thgrepo.WorkingParentChanged):
-            self.repositoryChanged.assert_called_once_with(flags)
-        if flags & thgrepo.WorkingBranchChanged:
-            self.workingBranchChanged.assert_called_once_with()
+        self.repositoryChanged.assert_called_once_with(flags)
         self.assertFalse(self.agent.isBusy(),
                          'repositoryChanged emitted while busy')
 
     def test_branch_and_parent_changed(self):
         self.agent.runCommandSequence([['update', '0'],
                                        ['branch', 'foo']])
-        # TODO: WorkingBranchChanged should be included
-        self.wait_changed(thgrepo.WorkingParentChanged
+        self.wait_changed(thgrepo.WorkingBranchChanged
+                          | thgrepo.WorkingParentChanged
                           | thgrepo.WorkingStateChanged)
 
     def test_listen_to_new_queue_changes(self):

tortoisehg/hgqt/commit.py

 
         repoagent.configChanged.connect(self.refresh)
         repoagent.repositoryChanged.connect(self.repositoryChanged)
-        repoagent.workingBranchChanged.connect(self.refresh)
         self._repoagent = repoagent
         repo = repoagent.rawRepo()
         self._cmdsession = cmdcore.nullCmdSession()
     def repositoryChanged(self, flags):
         if flags & thgrepo.WorkingParentChanged:
             self._refreshWorkingState()
+        elif flags & thgrepo.WorkingBranchChanged:
+            self.refresh()
 
     def _refreshWorkingState(self):
         curraction = self.mqgroup.checkedAction()

tortoisehg/hgqt/pbranch.py

 
         repoagent.configChanged.connect(self.configChanged)
         repoagent.repositoryChanged.connect(self.refresh)
-        repoagent.workingBranchChanged.connect(self.refresh)
 
         # Build child widgets
 

tortoisehg/hgqt/thgrepo.py

     configChanged = pyqtSignal()
     repositoryChanged = pyqtSignal(int)
     repositoryDestroyed = pyqtSignal()
-    workingBranchChanged = pyqtSignal()
 
     serviceStopped = pyqtSignal()
     busyChanged = pyqtSignal(bool)
     @pyqtSlot(int)
     def _onRepositoryChanged(self, flags):
         self._repo.thginvalidate()
-        # mimic precedence in watcher.pollStatus()
-        if flags & WorkingParentChanged:
-            flags &= ~WorkingBranchChanged  # mask state of separate signal
-            self._emitRepositoryChanged(flags)
-        elif flags & WorkingBranchChanged:
-            self.workingBranchChanged.emit()
-        elif flags & LogChanged:
+        # ignore signal that just contains internal flags
+        if flags & ~WorkingStateChanged:
             self._emitRepositoryChanged(flags)
 
     @pyqtSlot()