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