Commits

Yuya Nishihara committed 115718c

repoagent_test: add stub for flags describing changes occur in repository

To implement precise control of reloading, change notification signals are
planned to be merged into repositoryChanged(flags).

This patch updates the test case for easier support of signals other than
repositoryChanged().

Comments (0)

Files changed (2)

tests/qt_repoagent_test.py

             loop.exec_()
         self.assertFalse(self.agent.isBusy(), 'timeout while busy')
 
-    def wait_changed(self, timeout=5000):
+    def wait_changed(self, flags, timeout=5000):
         self.repositoryChanged.reset_mock()
         loop = QEventLoop()
         self.agent.repositoryChanged.connect(loop.quit)
         QTimer.singleShot(timeout, loop.quit)
         loop.exec_()
-        self.repositoryChanged.assert_called_once_with()
+        if flags & (thgrepo.LogChanged | thgrepo.WorkingParentChanged):
+            self.repositoryChanged.assert_called_once_with()
         self.assertFalse(self.agent.isBusy(),
                          'repositoryChanged emitted while busy')
 
     def test_filesystem_watcher(self):
         self.hg.update('0')
-        self.wait_changed()
+        self.wait_changed(thgrepo.WorkingParentChanged)
 
     def test_poll_on_command_finished(self):
         self.agent.runCommandSequence([['update', '0'], ['root']])
-        self.wait_changed()
+        self.wait_changed(thgrepo.WorkingParentChanged)
 
     def test_invalidate_on_dirstate_changed(self):
         repo = self.agent.rawRepo()
         self.agent.runCommand(['root'])
         self.agent.setHiddenRevsIncluded(not self.agent.hiddenRevsIncluded())
         self.assertFalse(self.repositoryChanged.called)
-        self.wait_changed()
+        self.wait_changed(thgrepo.LogChanged)
 
     def test_immediate_overlay(self):
         self.agent.setOverlay('union:%s' % self.hg2.path)
         self.agent.runCommand(['root'])
         self.agent.setOverlay('union:%s' % self.hg2.path)
         self.assertFalse(self.repositoryChanged.called)
-        self.wait_changed()
+        self.wait_changed(thgrepo.LogChanged)
 
     def test_clearoverlay_while_command_running(self):
         self.agent.setOverlay('union:%s' % self.hg2.path)
         self.agent.runCommand(['root'])
         self.agent.clearOverlay()
         self.assertFalse(self.repositoryChanged.called)
-        self.wait_changed()
+        self.wait_changed(thgrepo.LogChanged)

tortoisehg/hgqt/thgrepo.py

         return repo.filtered('visible')
 
 
+# flags describing changes that could occur in repository
+LogChanged = 0x1
+WorkingParentChanged = 0x2
+
+
 class _LockStillHeld(Exception):
     'Raised to abort status check due to lock existence'