Commits

Angel Ezquerra committed ecadf93

repowidget: add setting to automatically refresh the status list when it is shown

A new thg/refreshwdstatus setting has been introduced. This setting can have
3 values:

- auto: This is the default, and is the behavior up to this revision.
Refresh the status widget automatically, except when thg performs an
action that is certain to have modified the working directory status
- always: Always refresh the status whenever the user clicks on the commit button
on the task toolbar or when the user clicks on the "Working Directory"
revision
- local: Same as "always", but only for local (i.e. non network) repositories.

The default is setting is 'auto'.

Notes:
- No GUI for this setting has been added on this revision (will be done later).
- This solves a long standing issue in which TortoiseHg does not always detect
changes on the working copy. The only solution up until now was to click the
refresh button whenever you thought that the status window was not up to date.
This patch introduces an alternative, where the user can force the automatic
refresh of the status list whenever he switches to the commit widget.

The downside of enabling this setting is that it may slow down TortoiseHg in
very big repos, particularly if they are networked. However, I think that making
this a configurable behaviour, with the default being set to not refresh the
commit automatically, properly addresses the problem. If the user thinks that
the trade off of convenience vs performance is worth it he can set this setting.
If he doesn't the behavior of TortoiseHg will not change. In addition it is
possible to enable the auto refresh for local repos only.

- The approach taken on this patch may result in refreshing the status
widget twice when thg detects that there has been a change and automatically
reloads the status widget.

Comments (0)

Files changed (2)

tortoisehg/hgqt/commit.py

         self.refresh()
 
     @pyqtSlot()
+    def refreshWctx(self):
+        'User has requested a working context refresh'
+        self.stwidget.refreshWctx() # Trigger reload of working context
+
+    @pyqtSlot()
     def reload(self):
         'User has requested a reload'
         self.repo.thginvalidate()

tortoisehg/hgqt/repowidget.py

 
 from mercurial import revset, error, patch
 
-from tortoisehg.util import hglib, shlib
+from tortoisehg.util import hglib, shlib, paths
 
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.hgqt import qtlib
     def switchToNamedTaskTab(self, tabname):
         if tabname in self.namedTabs:
             idx = self.namedTabs[tabname]
+            if tabname == 'commit':
+                self._refreshCommitTabIfNeeded()
             self.taskTabsWidget.setCurrentIndex(idx)
 
             # restore default splitter position if task tab is invisible
         ctx = self.repo.changectx(rev)
         if rev is None or ('mq' in self.repo.extensions() and 'qtip' in ctx.tags()):
             # Clicking on working copy switches to commit tab
+            self._refreshCommitTabIfNeeded()
             tw.setCurrentIndex(self.commitTabIndex)
         else:
             # Clicking on a normal revision switches from commit tab
             return
         self.repo.incrementBusyCount()
         self.runner.run(*cmdlines)
+
+    def _refreshCommitTabIfNeeded(self):
+        """Refresh the Commit tab if the user settings require it"""
+        refreshwd = self.repo.ui.config('tortoisehg', 'refreshwdstatus', 'auto')
+        # Valid refreshwd values are 'auto', 'always' and 'alwayslocal'
+        if refreshwd != 'auto':
+            if refreshwd == 'always' \
+                    or not paths.netdrive_status(self.repo.root):
+                self.commitDemand.forward('refreshWctx')