Commits

Anonymous committed 66aa04a

settings, repowidget: add settings to select default widget and initial revision (closes #399)

Issue #399 proposes being able to let tortoisehg to select the working directory
when opening a repository.

This patch adds two new settings that not only allow configuring tortoisehg as
requested on issue #399, but also allow the user to select his preferred widget,
which can be any of the tortoisehg widgets (revision details, commit, manifest,
sync or search). This preferred widget is the one that will be selected by
default when opening a repository.

In addition, this patch adds a setting to select which revision should be
selected by default when opening a repository. It is possible to select the
current (i.e. the working directory parent) revision, the tip of the repository
or the working directory revision.

These two settings can be combined in interesting ways. For example it is
possible to make the commit widget the default while selecting the current
revision by default. It is also possible to make the working directory the
default and make the commit widget the default.

Note that when the working directory and the revision details widget are
selected by default, the commit widget will be selected instead.

  • Participants
  • Parent commits bf5aeb1
  • Branches stable

Comments (0)

Files changed (2)

File tortoisehg/hgqt/repowidget.py

         self.basenode = None
         self.destroyed.connect(self.repo.thginvalidate)
 
+        # Determine the "initial revision" that must be shown when
+        # opening the repo.
+        # The "initial revision" can be selected via the settings, and it can
+        # have 3 possible values:
+        # - "current":    Select the current (i.e. working dir parent) revision
+        # - "tip":        Select tip of the repository
+        # - "workingdir": Select the working directory pseudo-revision
+        initialRevision= \
+            self.repo.ui.config('tortoisehg', 'initialrevision', 'current').lower()
+
+        initialRevisionDict = {
+            'current': '.',
+            'tip': 'tip',
+            'workingdir': None
+        }
+        if initialRevision in initialRevisionDict:
+            default_rev = initialRevisionDict[initialRevision]
+        else:
+            # By default we'll select the current (i.e. working dir parent) revision
+            default_rev = '.'
+
         if repo.parents()[0].rev() == -1:
             self._reload_rev = 'tip'
         else:
-            self._reload_rev = '.'
+            self._reload_rev = default_rev
         self.currentMessage = ''
         self.dirty = False
 
         self.runner.makeLogVisible.connect(self.makeLogVisible)
         self.runner.commandFinished.connect(self.onCommandFinished)
 
+        # Select the widget chosen by the user
+        defaultWidget = \
+            self.repo.ui.config(
+                'tortoisehg', 'defaultwidget', 'revdetails').lower()
+        widgetDict = {
+            'revdetails': self.logTabIndex,
+            'commit': self.commitTabIndex,
+            'mq': self.mqTabIndex,
+            'sync': self.syncTabIndex,
+            'manifest': self.manifestTabIndex,
+            'search': self.grepTabIndex
+        }
+        if initialRevision == 'workingdir':
+            # Do not allow selecting the revision details widget when the
+            # selected revision is the working directory pseudo-revision
+            widgetDict['revdetails'] = self.commitTabIndex
+
+        if defaultWidget in widgetDict:
+            widgetIndex = widgetDict[defaultWidget]
+            # Note: if the mq extension is not enabled, self.mqTabIndex will
+            #       be negative
+            if widgetIndex > 0:
+                self.taskTabsWidget.setCurrentIndex(widgetIndex)
+
     def setupUi(self):
         SP = QSizePolicy
 

File tortoisehg/hgqt/settings.py

     )),
 
 ({'name': 'log', 'label': _('Workbench'), 'icon': 'menulog'}, (
+    _fi(_('Default widget'), 'tortoisehg.defaultwidget', (genDefaultCombo,
+        ['revdetails', 'commit', 'mq', 'sync', 'manifest', 'search']),
+        _('Select the initial widget that will be shown when opening a '
+        'repository. '
+        'Default: revdetails')),
+    _fi(_('Initial revision'), 'tortoisehg.initialrevision', (genDefaultCombo,
+        ['current', 'tip', 'workingdir']),
+        _('Select the initial revision that will be selected when opening a '
+        'repository.  You can select the "current" (i.e. the working directory '
+        'parent), the current "tip" or the working directory ("workingdir"). '
+        'Default: current')),
     _fi(_('Author Coloring'), 'tortoisehg.authorcolor', genBoolCombo,
         _('Color changesets by author name.  If not enabled, '
           'the changes are colored green for merge, red for '