Commits

Yuya Nishihara committed 2a3a5da

command running

Comments (0)

Files changed (3)

+# HG changeset patch
+# Date 1372951699 -32400
+# Parent 6a74f3418fbf5c7ce6910dbbac14cc59734f7237
+thgrepo: provide flag and signal to know busy state of command execution
+
+diff --git a/tests/qt_repomanager_test.py b/tests/qt_repomanager_test.py
+--- a/tests/qt_repomanager_test.py
++++ b/tests/qt_repomanager_test.py
+@@ -13,6 +13,7 @@ MAPPED_SIGNALS = [
+     ('configChanged', ()),
+     ('repositoryChanged', ()),
+     ('repositoryDestroyed', ()),
++    ('commandRunningChanged', (False,)),
+     ]
+ 
+ class RepoManagerMockedTest(unittest.TestCase):
+diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
+--- a/tortoisehg/hgqt/thgrepo.py
++++ b/tortoisehg/hgqt/thgrepo.py
+@@ -285,6 +285,8 @@ class RepoAgent(QObject):
+     workingDirectoryChanged = pyqtSignal()
+     workingBranchChanged = pyqtSignal()
+ 
++    commandRunningChanged = pyqtSignal(bool)
++
+     def __init__(self, repo):
+         QObject.__init__(self)
+         self._repo = repo
+@@ -318,7 +320,7 @@ class RepoAgent(QObject):
+             dbgoutput('not watching F/S events for bundle repository')
+         elif monitorrepo == 'localonly' and paths.netdrive_status(repo.path):
+             dbgoutput('not watching F/S events for network drive')
+-        elif self._busycount > 0:
++        elif self.isCommandRunning():
+             dbgoutput('not watching F/S events while busy')
+         else:
+             self._watcher.startMonitoring()
+@@ -338,16 +340,22 @@ class RepoAgent(QObject):
+         """Force checking changes to emit corresponding signals"""
+         self._watcher.pollStatus()
+ 
++    def isCommandRunning(self):
++        # assumes busycount is incremented before running command
++        return self._busycount > 0
++
+     def _incrementBusyCount(self):
+-        if self._busycount == 0:
++        self._busycount += 1
++        if self._busycount == 1:
+             self.stopMonitoring()
+-        self._busycount += 1
++            self.commandRunningChanged.emit(self.isCommandRunning())
+ 
+     def _decrementBusyCount(self):
+         self._busycount -= 1
+         if self._busycount == 0:
+             self.pollStatus()
+             self.startMonitoringIfEnabled()
++            self.commandRunningChanged.emit(self.isCommandRunning())
+         else:
+             # A lot of logic will depend on invalidation happening within
+             # the context of this call. Signals will not be emitted till later,
+@@ -372,6 +380,8 @@ class RepoManager(QObject):
+     repositoryChanged = pyqtSignal(unicode)
+     repositoryDestroyed = pyqtSignal(unicode)
+ 
++    commandRunningChanged = pyqtSignal(bool, unicode)
++
+     def __init__(self, ui, parent=None):
+         super(RepoManager, self).__init__(parent)
+         self._ui = ui
+@@ -426,6 +436,7 @@ class RepoManager(QObject):
+             (agent.configChanged,           self._mapConfigChanged),
+             (agent.repositoryChanged,       self._mapRepositoryChanged),
+             (agent.repositoryDestroyed,     self._mapRepositoryDestroyed),
++            (agent.commandRunningChanged,   self._mapCommandRunningChanged),
+             ]
+ 
+     #@pyqtSlot()
+@@ -444,6 +455,11 @@ class RepoManager(QObject):
+         agent.stopMonitoring()  # avoid further changed/destroyed signals
+         self.repositoryDestroyed.emit(agent.rootPath())
+ 
++    #@pyqtSlot(bool)
++    def _mapCommandRunningChanged(self, running):
++        agent = self.sender()
++        self.commandRunningChanged.emit(running, agent.rootPath())
++
+ 
+ _uiprops = '''_uifiles postpull tabwidth maxdiff
+               deadbranches _exts _thghiddentags displayname summarylen
+commandbusy.diff
+setrepo.diff
 refreshwctx-trace.diff
 wbatext-abrt.diff
 wb-openrepo-trace.diff
+# HG changeset patch
+# Parent 8898cc1a6d298374f2255279daa631af0b12a365
+
+diff --git a/tortoisehg/hgqt/docklog.py b/tortoisehg/hgqt/docklog.py
+--- a/tortoisehg/hgqt/docklog.py
++++ b/tortoisehg/hgqt/docklog.py
+@@ -271,15 +271,17 @@ class ConsoleWidget(QWidget):
+ 
+     _cmdtable = _ConsoleCmdTable()
+ 
+-    def __init__(self, parent=None):
++    def __init__(self, repo=None, parent=None):
+         super(ConsoleWidget, self).__init__(parent)
+         self.setLayout(QVBoxLayout())
+         self.layout().setContentsMargins(0, 0, 0, 0)
+         self._initlogwidget()
+         self.setFocusProxy(self._logwidget)
+-        self.setRepository(None)
+         self.openPrompt()
+         self.suppressPrompt = False
++        self._repo = repo
++        if self._repo:
++            self._logwidget.setPrompt('%s%% ' % self._repo.displayname)
+         self._commandHistory = []
+         self._commandIdx = 0
+ 
+@@ -441,11 +443,6 @@ class ConsoleWidget(QWidget):
+             if not self.suppressPrompt:
+                 self.openPrompt()
+ 
+-    def setRepository(self, repo):
+-        """Change the current working repository"""
+-        self._repo = repo
+-        self._logwidget.setPrompt('%s%% ' % (repo and repo.displayname or ''))
+-
+     def repoRootPath(self):
+         if self._repo:
+             return hglib.tounicode(self._repo.root)
+@@ -581,8 +578,7 @@ class LogDockWidget(QDockWidget):
+                 return w
+ 
+     def _createConsoleFor(self, repo):
+-        w = ConsoleWidget(self)
+-        w.setRepository(repo)
++        w = ConsoleWidget(repo, self)
+         w.closeRequested.connect(self.close)
+         w.progressReceived.connect(self.progressReceived)
+         self._consoles.addWidget(w)