##// END OF EJS Templates
inotify: add client code for long pathname handling
Benoit Boissinot -
r7024:ee308d44 default
parent child Browse files
Show More
@@ -1,55 +1,62
1 1 # client.py - inotify status client
2 2 #
3 3 # Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com>
4 4 # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com>
5 5 #
6 6 # This software may be used and distributed according to the terms
7 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 9 from mercurial.i18n import gettext as _
10 10 from mercurial import ui
11 11 import common
12 12 import os, select, socket, stat, struct, sys
13 13
14 14 def query(ui, repo, names, match, list_ignored, list_clean, list_unknown=True):
15 15 sock = socket.socket(socket.AF_UNIX)
16 16 sockpath = repo.join('inotify.sock')
17 sock.connect(sockpath)
17 try:
18 sock.connect(sockpath)
19 except socket.error, err:
20 if err[0] == "AF_UNIX path too long":
21 sockpath = os.readlink(sockpath)
22 sock.connect(sockpath)
23 else:
24 raise
18 25
19 26 def genquery():
20 27 for n in names or []:
21 28 yield n
22 29 states = 'almrx!'
23 30 if list_ignored:
24 31 raise ValueError('this is insanity')
25 32 if list_clean: states += 'n'
26 33 if list_unknown: states += '?'
27 34 yield states
28 35
29 36 req = '\0'.join(genquery())
30 37
31 38 sock.sendall(chr(common.version))
32 39 sock.sendall(req)
33 40 sock.shutdown(socket.SHUT_WR)
34 41
35 42 cs = common.recvcs(sock)
36 43 version = ord(cs.read(1))
37 44
38 45 if version != common.version:
39 46 ui.warn(_('(inotify: received response from incompatible server '
40 47 'version %d)\n') % version)
41 48 return None
42 49
43 50 try:
44 51 resphdr = struct.unpack(common.resphdrfmt, cs.read(common.resphdrsize))
45 52 except struct.error:
46 53 return None
47 54
48 55 def readnames(nbytes):
49 56 if nbytes:
50 57 names = cs.read(nbytes)
51 58 if names:
52 59 return filter(match, names.split('\0'))
53 60 return []
54 61
55 62 return map(readnames, resphdr)
@@ -1,9 +1,7
1 1 % fail
2 failed to contact inotify server: AF_UNIX path too long
2 failed to contact inotify server: No such file or directory
3 3 deactivating inotify
4 4 abort: could not start server: File exists
5 5 % inserve
6 6 % status
7 failed to contact inotify server: AF_UNIX path too long
8 deactivating inotify
9 7 ? hg.pid
General Comments 0
You need to be logged in to leave comments. Login now