# Date 1376211495 -32400
# Sun Aug 11 17:58:15 2013 +0900
# Branch stable
# Node ID 89c3f499c0105969802ac33209c69072c4bb0109
# Parent dc741e5a657f6cad7b14d2fe4abbbf5b2c2077c1
thgrepo: recreate QFileSystemWatcher to restart monitoring (fixes #3298)
QWindowsFileSystemWatcherEngine seems to have a bug which makes monitoring
of ".hg" and ".hg/store" directory not restartable. After that, it cannot
detect deletion of lock files.
https://bugreports.qt-project.org/browse/QTBUG-32917
diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
--- a/tortoisehg/hgqt/thgrepo.py
+++ b/tortoisehg/hgqt/thgrepo.py
@@ -108,6 +108,14 @@ class RepoWatcher(QObject):
if files:
self._fswatcher.removePaths(files)
+ # QTBUG-32917: On Windows, removePaths() fails to remove ".hg" and
+ # ".hg/store" from the list, but actually they are not watched.
+ # Thus, they cannot be watched again by the same fswatcher instance.
+ if self._fswatcher.directories() or self._fswatcher.files():
+ dbgoutput('failed to remove paths - destroying watcher')
+ self._fswatcher.setParent(None)
+ self._fswatcher = None
+
def isMonitoring(self):
"""True if filesystem monitor is running"""
if not self._fswatcher: