Commits

Yuya Nishihara committed 64e5780

repofilter: fall back to "show all" if current branch is removed from list

  • Participants
  • Parent commits bc0c1f9
  • Branches stable

Comments (0)

Files changed (2)

tests/widget/repofilterbar_branch_test.py

         self.assertEqual(self.widget._allBranchesLabel,
                          unicode(self.widget._branchCombo.currentText()))
 
+    def test_selected_inactive_branch_removed_from_list(self):
+        self.widget.setBranch('default')
+        self.branchchanged.reset_mock()
+        self.widget._abranchAction.setChecked(False)
+        self.widget._abranchAction.trigger()  # checked
+        self.assertEqual('', self.widget.branch())  # fall back
+        self.branchchanged.assert_called_once_with('', False)
+
+    def test_selected_closed_branch_removed_from_list(self):
+        self.widget._cbranchAction.setChecked(False)
+        self.widget._cbranchAction.trigger()  # checked
+        self.widget.setBranch('baz')
+        self.branchchanged.reset_mock()
+        self.widget._cbranchAction.trigger()  # unchecked
+        self.assertEqual('', self.widget.branch())  # fall back
+        self.branchchanged.assert_called_once_with('', False)
+
 class RepoFilterBarEmptyBranchTest(unittest.TestCase):
     @classmethod
     def setUpClass(cls):

tortoisehg/hgqt/repofilter.py

                                           or self._abranchAction.isChecked()))
         self._branchReloading = False
 
-        self.setBranch(curbranch)
+        if curbranch and curbranch not in branches:
+            self._emitBranchChanged()  # falls back to "show all"
+        else:
+            self.setBranch(curbranch)
 
     @pyqtSlot(unicode)
     def setBranch(self, branch):