inotify: set a flag so a failed inotify query doesn't get repeated.
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Wed, 06 May 2009 01:40:03 +0900
changeset 8556 f5fae700cc00
parent 8555 3e09bc5fee12
child 8557 67f76a4463ef
inotify: set a flag so a failed inotify query doesn't get repeated. If, for some reason, we can't get the inotify server to start, it's better to disable inotify queries for the instance to avoid trying over and over to start the server, which takes time. Just fall back on repo.status()
hgext/inotify/__init__.py
--- a/hgext/inotify/__init__.py	Wed Apr 22 00:37:35 2009 +0900
+++ b/hgext/inotify/__init__.py	Wed May 06 01:40:03 2009 +0900
@@ -63,17 +63,24 @@
         # to recurse.
         inotifyserver = False
 
+        # We'll set this to false after an unsuccessful attempt so that
+        # next calls of status() within the same instance don't try again
+        # to start an inotify server if it won't start.
+        _inotifyon = True
+
         def status(self, match, ignored, clean, unknown=True):
             files = match.files()
             if '.' in files:
                 files = []
-            if not ignored and not self.inotifyserver:
+            if self._inotifyon and not ignored and not self.inotifyserver:
                 cli = client(ui, repo)
                 try:
                     result = cli.statusquery(files, match, False,
                                             clean, unknown)
                 except QueryFailed, instr:
                     ui.debug(str(instr))
+                    # don't retry within the same hg instance
+                    inotifydirstate._inotifyon = False
                     pass
                 else:
                     if ui.config('inotify', 'debug'):