diff hgext/inotify/__init__.py @ 7452:89c516430107

inotify: do not complain that inotify is not running if autostart is False
author Brendan Cully <brendan@kublai.com>
date Mon, 01 Dec 2008 14:06:02 -0800
parents cf7741aa1e96
children 2f4a399a8787
line wrap: on
line diff
--- a/hgext/inotify/__init__.py	Mon Dec 01 13:38:26 2008 -0800
+++ b/hgext/inotify/__init__.py	Mon Dec 01 14:06:02 2008 -0800
@@ -73,12 +73,13 @@
                     if result is not None:
                         return result
             except (OSError, socket.error), err:
+                autostart = ui.configbool('inotify', 'autostart', True)
+
                 if err[0] == errno.ECONNREFUSED:
                     ui.warn(_('(found dead inotify server socket; '
                                    'removing it)\n'))
                     os.unlink(repo.join('inotify.sock'))
-                if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and \
-                        ui.configbool('inotify', 'autostart', True):
+                if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
                     query = None
                     ui.debug(_('(starting inotify server)\n'))
                     try:
@@ -100,8 +101,9 @@
                         except socket.error, err:
                             ui.warn(_('could not talk to new inotify '
                                            'server: %s\n') % err[-1])
-                elif err[0] == errno.ENOENT:
-                    ui.warn(_('(inotify server not running)\n'))
+                elif err[0] in (errno.ECONNREFUSED, errno.ENOENT):
+                    # silently ignore normal errors if autostart is False
+                    ui.debug(_('(inotify server not running)\n'))
                 else:
                     ui.warn(_('failed to contact inotify server: %s\n')
                              % err[-1])