# HG changeset patch # User Benoit Boissinot # Date 1220698160 -7200 # Node ID fecf060f32a13ca4e22d0d3ce3369c18e3f70687 # Parent 25619b72f86aa026f251a14b348a0a67bd9fe75f inotify: deactivate inotify status on failure workaround issue1208, add test fix traceback handling (socket.error is a singleton in this case) diff -r 25619b72f86a -r fecf060f32a1 hgext/inotify/__init__.py --- a/hgext/inotify/__init__.py Sat Sep 06 12:48:52 2008 +0200 +++ b/hgext/inotify/__init__.py Sat Sep 06 12:49:20 2008 +0200 @@ -63,9 +63,8 @@ ui.warn(_('(found dead inotify server socket; ' 'removing it)\n')) os.unlink(repo.join('inotify.sock')) - elif err[0] != errno.ENOENT: - raise - if ui.configbool('inotify', 'autostart'): + if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and \ + ui.configbool('inotify', 'autostart'): query = None ui.debug(_('(starting inotify server)\n')) try: @@ -79,16 +78,20 @@ except Exception, inst: ui.warn(_('could not start inotify server: ' '%s\n') % inst) - ui.print_exc() - if query: try: return query(ui, repo, files or [], match, list_ignored, list_clean, list_unknown) except socket.error, err: ui.warn(_('could not talk to new inotify ' - 'server: %s\n') % err[1]) - ui.print_exc() + 'server: %s\n') % err[-1]) + else: + ui.warn(_('failed to contact inotify server: %s\n') + % err[-1]) + ui.print_exc() + # replace by old status function + ui.warn(_('deactivating inotify\n')) + self.status = super(inotifydirstate, self).status return super(inotifydirstate, self).status( files, match or util.always, list_ignored, list_clean, diff -r 25619b72f86a -r fecf060f32a1 tests/hghave --- a/tests/hghave Sat Sep 06 12:48:52 2008 +0200 +++ b/tests/hghave Sat Sep 06 12:49:20 2008 +0200 @@ -57,6 +57,13 @@ finally: os.remove(path) +def has_inotify(): + try: + import hgext.inotify.linux.watcher + return True + except ImportError: + return False + def has_fifo(): return hasattr(os, "mkfifo") @@ -129,14 +136,15 @@ "fifo": (has_fifo, "named pipes"), "git": (has_git, "git command line client"), "hotshot": (has_hotshot, "python hotshot module"), + "inotify": (has_inotify, "inotify extension support"), "lsprof": (has_lsprof, "python lsprof module"), "mtn": (has_mtn, "monotone client (> 0.31)"), + "pygments": (has_pygments, "Pygments source highlighting library"), "svn": (has_svn, "subversion client and admin tools"), "svn-bindings": (has_svn_bindings, "subversion python bindings"), "symlink": (has_symlink, "symbolic links"), "tla": (has_tla, "GNU Arch tla client"), "unix-permissions": (has_unix_permissions, "unix-style permissions"), - "pygments": (has_pygments, "Pygments source highlighting library"), } def list_features(): diff -r 25619b72f86a -r fecf060f32a1 tests/test-inotify-issue1208 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-inotify-issue1208 Sat Sep 06 12:49:20 2008 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh + +"$TESTDIR/hghave" inotify || exit 80 + +echo "[extensions]" >> $HGRCPATH +echo "inotify=" >> $HGRCPATH + +p="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +hg init $p +cd $p + +echo % inserve +hg inserve +echo % status +hg status diff -r 25619b72f86a -r fecf060f32a1 tests/test-inotify-issue1208.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-inotify-issue1208.out Sat Sep 06 12:49:20 2008 +0200 @@ -0,0 +1,5 @@ +% inserve +abort: AF_UNIX path too long +% status +failed to contact inotify server: AF_UNIX path too long +deactivating inotify