Issue1208

Title inotify: "hg ci" fails when working directory name is longer than 108 bytes
Priority bug Status resolved
Superseder Nosy List djc, meyering, pmezard, tonfa, warner
Assigned To Topics inotify, patch

Created on 2008-06-30.15:13:04 by meyering, last changed 2008-09-15.08:31:29 by djc.

Messages
msg7140 (view) Author: djc Date: 2008-09-15.08:31:29
Okay, resolving.
msg7139 (view) Author: tonfa Date: 2008-09-15.08:30:11
Yes (there's a bunch of remaining inotify issues, but since now I'm adding tests
when I resolve them, it should be better in the future).
msg7133 (view) Author: djc Date: 2008-09-15.08:10:32
So this is fixed now, right?
msg6978 (view) Author: warner Date: 2008-09-07.02:54:34
ah, I see something equivalent (inst[-1]) is in the crew repo. Assuming that
makes it into trunk eventually, it looks like that's enough.
msg6977 (view) Author: warner Date: 2008-09-07.02:45:57
I just hit the same problem, and disabling the inotify extension resolved it.
But I'm thinking that maybe we should fix the error-reporting bug too:

diff -r 6dcbe191a9b5 mercurial/dispatch.py
--- a/mercurial/dispatch.py     Mon Aug 18 16:50:36 2008 -0500
+++ b/mercurial/dispatch.py     Sat Sep 06 19:36:25 2008 -0700
@@ -90,7 +90,7 @@
             else:
                 raise
     except socket.error, inst:
-        ui.warn(_("abort: %s\n") % inst[1])
+        ui.warn(_("abort: %s\n") % inst)
     except IOError, inst:
         if hasattr(inst, "code"):
             ui.warn(_("abort: %s\n") % inst)
msg6969 (view) Author: tonfa Date: 2008-09-06.15:13:27
9c4e488f105e in stable
msg6966 (view) Author: tonfa Date: 2008-09-05.23:41:35
It doesn't fully solve it but at least you're able to use your repo.
msg6965 (view) Author: tonfa Date: 2008-09-05.23:39:32
# 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
msg6962 (view) Author: tonfa Date: 2008-09-05.21:54:30
from man 7 unix:
#define UNIX_PATH_MAX    108
struct sockaddr_un {
    sa_family_t    sun_family;               /* AF_UNIX */
    char           sun_path[UNIX_PATH_MAX];  /* pathname */
};
msg6600 (view) Author: pmezard Date: 2008-07-25.19:22:50
Making title more specific
msg6599 (view) Author: meyering Date: 2008-07-25.19:17:44
when I comment out the "hgext.inotify =" line of /etc/mercurial/hgrc.d/hgext.rc,
that makes the test pass.  So it *is* inotify-specific.
msg6595 (view) Author: pmezard Date: 2008-07-25.18:23:46
Enabled extensions are displayed in the [extensions] section output by hg
shoconfig. To disable it, just comment the relevant line in your .hgrc with a #
or a semi-colon.
msg6464 (view) Author: meyering Date: 2008-07-03.10:35:57
Patrick Mézard <mercurial-bugs@selenic.com> wrote:
> Patrick Mézard <pmezard@gmail.com> added the comment:
>
> Can you try without the inotify extension, so we can pinpoint the issue ?

Hi Patrick,

Sure.  I don't know the recommended way to disable an extension,
but I ran chmod 0 on the installed $prefix/lib/python/hgext/inotify
directory and then re-ran the reproducer.  Same failure.
msg6457 (view) Author: pmezard Date: 2008-07-01.14:55:49
Can you try without the inotify extension, so we can pinpoint the issue ?
msg6450 (view) Author: meyering Date: 2008-06-30.15:13:03
This is using a version of hg built from latest sources a few minutes ago
on a debian unstable system (with python 2.5.2):
    $ hg --version
    Mercurial Distributed SCM (version 1.0.1)
                                   
    $ d=$(perl -e 'print "/tmp/"."x"x86'); \
    mkdir $d && cd $d && hg init && touch f && hg add f && hg ci -m.; \
    rm -rf $d
    adding f
    Traceback (most recent call last):
      File "/usr/bin/hg", line 20, in <module>
        mercurial.dispatch.run()
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 20,
in run
        sys.exit(dispatch(sys.argv[1:]))
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 29,
in dispatch
        return _runcatch(u, args)
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 93,
in _runcatch
        ui.warn(_("abort: %s\n") % inst[1])
    IndexError: tuple index out of range


The above may look contrived, but the underlying bug
caused a new test failure in my vc-dwim package.


Rerunning the failing command with --traceback gives this:

    $ hg --traceback ci -m.
    Traceback (most recent call last):
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 45,
in _runcatch
        return _dispatch(ui, args)
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 364,
in _dispatch
        ret = _runcommand(ui, options, cmd, d)
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 417,
in _runcommand
        return checkargs()
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 373,
in checkargs
        return cmdfunc()
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 356,
in <lambda>
        d = lambda: func(ui, repo, *args, **cmdoptions)
      File "/var/lib/python-support/python2.5/mercurial/commands.py", line 557,
in commit
        node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
      File "/var/lib/python-support/python2.5/mercurial/cmdutil.py", line 1179,
in commit
        return commitfunc(ui, repo, files, message, match, opts)
      File "/var/lib/python-support/python2.5/mercurial/commands.py", line 555,
in commitfunc
        force_editor=opts.get('force_editor'))
      File "/var/lib/python-support/python2.5/hgext/mq.py", line 2189, in commit
        return super(mqrepo, self).commit(*args, **opts)
      File "/var/lib/python-support/python2.5/mercurial/localrepo.py", line 774,
in commit
        changes = self.status(match=match)[:5]
      File "/var/lib/python-support/python2.5/mercurial/localrepo.py", line
1011, in status
        list_unknown)
      File "/var/lib/python-support/python2.5/hgext/inotify/__init__.py", line
55, in status
        list_clean, list_unknown)
      File "/var/lib/python-support/python2.5/hgext/inotify/client.py", line 17,
in query
        sock.connect(sockpath)
      File "<string>", line 1, in connect
    error: AF_UNIX path too long
    Traceback (most recent call last):
      File "/usr/bin/hg", line 20, in <module>
        mercurial.dispatch.run()
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 20,
in run
        sys.exit(dispatch(sys.argv[1:]))
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 29,
in dispatch
        return _runcatch(u, args)
      File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 93,
in _runcatch
        ui.warn(_("abort: %s\n") % inst[1])
    IndexError: tuple index out of range
History
Date User Action Args
2008-09-15 08:31:29djcsetstatus: testing -> resolved
nosy: tonfa, meyering, pmezard, djc, warner
messages: + msg7140
2008-09-15 08:30:17tonfasettopic: + inotify
nosy: tonfa, meyering, pmezard, djc, warner
2008-09-15 08:30:11tonfasetnosy: tonfa, meyering, pmezard, djc, warner
messages: + msg7139
2008-09-15 08:10:32djcsetnosy: + djc
messages: + msg7133
2008-09-07 02:54:35warnersetnosy: tonfa, meyering, pmezard, warner
messages: + msg6978
2008-09-07 02:45:58warnersetnosy: + warner
messages: + msg6977
2008-09-06 15:13:28tonfasetstatus: in-progress -> testing
nosy: tonfa, meyering, pmezard
messages: + msg6969
2008-09-05 23:41:36tonfasetnosy: tonfa, meyering, pmezard
messages: + msg6966
2008-09-05 23:41:16tonfasetstatus: chatting -> in-progress
nosy: tonfa, meyering, pmezard
2008-09-05 23:39:34tonfasettopic: + patch
nosy: tonfa, meyering, pmezard
messages: + msg6965
2008-09-05 21:54:31tonfasetnosy: + tonfa
messages: + msg6962
title: inotify: "hg ci" fails when working directory name is longer than 90 bytes -> inotify: "hg ci" fails when working directory name is longer than 108 bytes
2008-07-25 19:22:54pmezardsetnosy: meyering, pmezard
messages: + msg6600
title: "hg ci" fails when working directory name is longer than 90 bytes -> inotify: "hg ci" fails when working directory name is longer than 90 bytes
2008-07-25 19:17:45meyeringsetnosy: meyering, pmezard
messages: + msg6599
2008-07-25 18:23:46pmezardsetnosy: meyering, pmezard
messages: + msg6595
2008-07-03 10:35:58meyeringsetnosy: meyering, pmezard
messages: + msg6464
2008-07-01 14:55:52pmezardsetstatus: unread -> chatting
nosy: + pmezard
messages: + msg6457
2008-06-30 15:13:04meyeringcreate