Commits

Yuya Nishihara  committed bc0c1f9

repofilter: assume that first item of branchCombo is "show all"

It's simpler than testing if "show all" label matches the combo box text.
Also setBranch() shouldn't recognize "show all" label, which is private.

  • Participants
  • Parent commits b8d4cce
  • Branches stable

Comments (0)

Files changed (2)

File tests/widget/repofilterbar_branch_test.py

         self.assertEqual('foo', self.widget.branch())
         self.branchchanged.assert_called_once_with('foo', False)
 
+    def test_label_for_all_branches(self):
+        self.widget.setBranch('')  # all branches
+        self.assertEqual('', self.widget.branch())
+        self.assertEqual(self.widget._allBranchesLabel,
+                         unicode(self.widget._branchCombo.currentText()))
+
 class RepoFilterBarEmptyBranchTest(unittest.TestCase):
     @classmethod
     def setUpClass(cls):

File tortoisehg/hgqt/repofilter.py

                                           or self._abranchAction.isChecked()))
         self._branchReloading = False
 
-        if not curbranch:
-            curbranch = self._allBranchesLabel
         self.setBranch(curbranch)
 
     @pyqtSlot(unicode)
     def setBranch(self, branch):
         """Change the current branch by name [unicode]"""
-        self._branchCombo.setCurrentIndex(self._branchCombo.findText(branch))
+        if not branch:
+            index = 0
+        else:
+            index = self._branchCombo.findText(branch)
+        if index >= 0:
+            self._branchCombo.setCurrentIndex(index)
 
     def branch(self):
         """Return the current branch name [unicode]"""
-        curbranch = self._branchCombo.currentText()
-        if curbranch == self._allBranchesLabel:
-            curbranch = ''
-        return unicode(curbranch)
+        if self._branchCombo.currentIndex() == 0:
+            return ''
+        else:
+            return unicode(self._branchCombo.currentText())
 
     @pyqtSlot()
     def _emitBranchChanged(self):