Commits

Yuya Nishihara  committed a1be949

branch filter improvements

  • Participants
  • Parent commits b368a66

Comments (0)

Files changed (6)

File branchallpare.diff

+# HG changeset patch
+# Parent b3d8fa2d1d76d60211d30afd3366d61bfa7b4021
+repomodel: change default of branch filter to allparents=False
+
+It resolves the incongruity of the initial state between repomodel and
+repofilter.
+
+Also removed default value from RepoWidget's setBranch(), which is a slot
+for RepoFilterBar.branchChanged.
+
+diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
+--- a/tortoisehg/hgqt/repomodel.py
++++ b/tortoisehg/hgqt/repomodel.py
+@@ -170,7 +170,7 @@ class HgRepoListModel(QAbstractTableMode
+         for branch in sorted(self.repo.branchtags().keys()):
+             self.namedbranch_color(branch)
+ 
+-    def setBranch(self, branch=None, allparents=True):
++    def setBranch(self, branch=None, allparents=False):
+         self.filterbranch = branch  # unicode
+         self.invalidateCache()
+         if self.revset and self.filterbyrevset:
+diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
+--- a/tortoisehg/hgqt/repowidget.py
++++ b/tortoisehg/hgqt/repowidget.py
+@@ -994,7 +994,7 @@ class RepoWidget(QWidget):
+             self.taskTabsWidget.tabBar().hide()
+ 
+     @pyqtSlot(QString, bool)
+-    def setBranch(self, branch, allparents=True):
++    def setBranch(self, branch, allparents):
+         'Change the branch filter'
+         self.repomodel.setBranch(branch=branch, allparents=allparents)
+         self.titleChanged.emit(self.title())

File repow-noubranch.diff

+# HG changeset patch
+# Parent 97fa9fa288576ce7585f5c7b4649ed887f493387
+repowidget: don't duplicate filter branch name
+
+diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
+--- a/tortoisehg/hgqt/repowidget.py
++++ b/tortoisehg/hgqt/repowidget.py
+@@ -70,7 +70,6 @@ class RepoWidget(QWidget):
+         repo.repositoryDestroyed.connect(self.repositoryDestroyed)
+         repo.configChanged.connect(self.configChanged)
+         self.revsetfilter = False
+-        self.ubranch = u''
+         self.bundle = None  # bundle file name [local encoding]
+         self.bundlesource = None  # source URL of incoming bundle [unicode]
+         self.outgoingMode = False
+@@ -271,8 +270,8 @@ class RepoWidget(QWidget):
+         """Returns the expected title for this widget [unicode]"""
+         if self.bundle:
+             return _('%s <incoming>') % self.repo.shortname
+-        elif self.ubranch:
+-            return u'%s [%s]' % (self.repo.shortname, self.ubranch)
++        elif self.repomodel.branch():
++            return u'%s [%s]' % (self.repo.shortname, self.repomodel.branch())
+         else:
+             return self.repo.shortname
+ 
+@@ -781,7 +780,7 @@ class RepoWidget(QWidget):
+         # Filter revision set in case revisions were removed
+         self.revset = [r for r in self.revset if r < len(self.repo)]
+         self.repomodel = HgRepoListModel(self.repo, self.repoview.colselect[0],
+-                                         self.ubranch, self.revset,
++                                         self.filterbar.branch(), self.revset,
+                                          self.revsetfilter, self)
+         self.repomodel.filled.connect(self.modelFilled)
+         self.repomodel.loaded.connect(self.modelLoaded)
+@@ -997,7 +996,6 @@ class RepoWidget(QWidget):
+     @pyqtSlot(QString, bool)
+     def setBranch(self, branch, allparents=True):
+         'Change the branch filter'
+-        self.ubranch = branch
+         self.repomodel.setBranch(branch=branch, allparents=allparents)
+         self.titleChanged.emit(self.title())
+         if self.revset:

File savebranch.diff

+# HG changeset patch
+# Parent 5612fbdeaa90d65b807496c1b6971ac3fb54444c
+repofilter: restore previously selected branch (closes #1009, #1927)
+
+diff --git a/tortoisehg/hgqt/repofilter.py b/tortoisehg/hgqt/repofilter.py
+--- a/tortoisehg/hgqt/repofilter.py
++++ b/tortoisehg/hgqt/repofilter.py
+@@ -200,6 +200,10 @@ class RepoFilterBar(QToolBar):
+         self.revsetcombo.addItems(full)
+         self.revsetcombo.setCurrentIndex(-1)
+ 
++        self._branchReloading = True
++        self.setBranch(s.value('revset/' + repoid + '/branch').toString())
++        self._branchReloading = False
++
+         # Show the filter bar if necessary
+         if s.value('revset/' + repoid + '/showrepofilterbar').toBool():
+             self.show()
+@@ -215,6 +219,7 @@ class RepoFilterBar(QToolBar):
+         s.setValue('revset/' + repoid + '/queries', self.revsethist)
+         s.setValue('revset/' + repoid + '/filter', self.filtercb.isChecked())
+         s.setValue('revset/' + repoid + '/showrepofilterbar', not self.isHidden())
++        s.setValue('revset/' + repoid + '/branch', self.branch())
+ 
+     def _initbranchfilter(self):
+         self._branchLabel = QToolButton(
 sortbranch.diff
+repow-noubranch.diff
+branchallpare.diff
+savebranch.diff
+wb-title.diff
 reporeg-moveactions.diff
 reporeg-saverestore.diff
 reporeg-actdict.diff

File sortbranch.diff

 # HG changeset patch
 # Parent 6c42545dbd88959fd014c74a69b09cdf3eacaa7c
-repofilter: show working branch first (closes #2042)
+repofilter: show current working branch first (closes #2042)
 
-If you go feature-branch-style development, there're many short-term branches.
-which bursts branch combo box. In that case, the current branch would be
-accessed more often, let's give higher priority to it than others.
+If you go feature-branch development, there are many short-term branches,
+which bursts branch combo box. In that case, the current branch will be
+accessed more often, let's give higher priority to it.
 
 diff --git a/tests/widget/repofilterbar_branch_test.py b/tests/widget/repofilterbar_branch_test.py
 --- a/tests/widget/repofilterbar_branch_test.py
 -        if 'default' in branches:
 -            branches = ['default'] + \
 -                [branch for branch in branches if branch != 'default']
-+        # easy access to common branches
++        # easy access to common branches (Python sorted() is stable)
 +        priomap = {self._repo.dirstate.branch(): -2, 'default': -1}
-+        branches = sorted(branches, key=lambda e: priomap.get(e, 0))  # stable
++        branches = sorted(branches, key=lambda e: priomap.get(e, 0))
 +
          self._branchReloading = True
          self._branchCombo.clear()

File wb-title.diff

+# HG changeset patch
+# Parent 7cd003706e03805e1182da68235f27f82a2fed20
+workbench: show branch filter name and incoming state in window title
+
+diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
+--- a/tortoisehg/hgqt/workbench.py
++++ b/tortoisehg/hgqt/workbench.py
+@@ -655,21 +655,24 @@ class Workbench(QMainWindow):
+         self.updateTaskViewMenu()
+         self.updateToolBarActions()
+         tw = self.repoTabsWidget
+-        w = tw.currentWidget()
+         if ((tw.count() == 0) or
+             ((tw.count() == 1) and
+              not self.ui.configbool('tortoisehg', 'forcerepotab', False))):
+             tw.tabBar().hide()
+         else:
+             tw.tabBar().show()
++        self._updateWindowTitle()
++
++    def _updateWindowTitle(self):
++        tw = self.repoTabsWidget
++        w = tw.currentWidget()
+         if tw.count() == 0:
+             self.setWindowTitle(_('TortoiseHg Workbench'))
+         elif w.repo.shortname != w.repo.displayname:
+             self.setWindowTitle(_('%s - TortoiseHg Workbench - %s') %
+-                                (w.repo.shortname, w.repo.displayname))
++                                (w.title(), w.repo.displayname))
+         else:
+-            self.setWindowTitle(_('%s - TortoiseHg Workbench') %
+-                                w.repo.shortname)
++            self.setWindowTitle(_('%s - TortoiseHg Workbench') % w.title())
+ 
+     def updateToolBarActions(self):
+         w = self.repoTabsWidget.currentWidget()
+@@ -762,6 +765,13 @@ class Workbench(QMainWindow):
+         self.log.setRepository(repo)
+         self.mqpatches.setrepo(repo)
+ 
++    @pyqtSlot(unicode)
++    def _updateRepoTabTitle(self, title):
++        index = self.repoTabsWidget.indexOf(self.sender())
++        self.repoTabsWidget.setTabText(index, title)
++        if index == self.repoTabsWidget.currentIndex():
++            self._updateWindowTitle()
++
+     def addRepoTab(self, repo, bundle):
+         '''opens the given repo in a new tab'''
+         rw = RepoWidget(repo, self, bundle=bundle)
+@@ -792,8 +802,7 @@ class Workbench(QMainWindow):
+             index = self.repoTabsWidget.addTab(rw, rw.title())
+         tw.setTabToolTip(index, hglib.tounicode(repo.root))
+         tw.setCurrentIndex(index)
+-        rw.titleChanged.connect(
+-            lambda title: tw.setTabText(tw.indexOf(rw), title))
++        rw.titleChanged.connect(self._updateRepoTabTitle)
+         rw.showIcon.connect(
+             lambda icon: tw.setTabIcon(tw.indexOf(rw), icon))
+         self.reporegistry.addRepo(repo.root)