# HG changeset patch
# User Benoit Boissinot <benoit.boissinot@ens-lyon.org>
# Date 1220657587 -7200
# Node ID 0743b6c1c417a028e3de65cf725f2690402dac54
# Parent b9d012ce8578cec2e0788ed898f1d42389fafab1
inotify: disable inotify when unable to create socket (path too long)
workaround issue1208, add test
fix traceback handling (socket.error is a singleton in this case)
diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py
--- a/hgext/inotify/__init__.py
+++ b/hgext/inotify/__init__.py
@@ -84,7 +84,7 @@
list_ignored, list_clean, list_unknown)
except socket.error, err:
ui.warn(_('could not talk to new inotify '
- 'server: %s\n') % err[1])
+ 'server: %s\n') % err[-1])
ui.print_exc()
return super(inotifydirstate, self).status(
diff --git a/hgext/inotify/client.py b/hgext/inotify/client.py
--- a/hgext/inotify/client.py
+++ b/hgext/inotify/client.py
@@ -14,7 +14,13 @@
def query(ui, repo, names, match, list_ignored, list_clean, list_unknown=True):
sock = socket.socket(socket.AF_UNIX)
sockpath = repo.join('inotify.sock')
- sock.connect(sockpath)
+ try:
+ sock.connect(sockpath)
+ except socket.error, err:
+ if err[0] == "AF_UNIX path too long":
+ ui.warn(_('inotify: failed to connect to server: %s\n')
+ % err[0])
+ return
def genquery():
for n in names or []:
diff --git a/tests/hghave b/tests/hghave
--- a/tests/hghave
+++ b/tests/hghave
@@ -56,6 +56,13 @@
return (os.lstat(path).st_mode & 0100 != 0)
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 --git a/tests/test-inotify-issue1208 b/tests/test-inotify-issue1208
new file mode 100755
--- /dev/null
+++ b/tests/test-inotify-issue1208
@@ -0,0 +1,14 @@
+#!/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 --git a/tests/test-inotify-issue1208.out b/tests/test-inotify-issue1208.out
new file mode 100644
--- /dev/null
+++ b/tests/test-inotify-issue1208.out
@@ -0,0 +1,4 @@
+% inserve
+abort: AF_UNIX path too long
+% status
+inotify: failed to connect to server: AF_UNIX path too long |