Mercurial > hg
annotate hgext/inotify/client.py @ 7166:fb3df69aa785
hgweb: nodeids should be aligned in raw changesets
If they aren't it breaks hg import --exact
Thanks to Jesper Noehr for noticing it.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 19 Oct 2008 12:23:58 +0200 |
parents | 6f4a253f2a64 |
children | 59b4ae211584 |
rev | line source |
---|---|
6239 | 1 # client.py - inotify status client |
2 # | |
3 # Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com> | |
4 # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> | |
5 # | |
6 # This software may be used and distributed according to the terms | |
7 # of the GNU General Public License, incorporated herein by reference. | |
8 | |
9 from mercurial.i18n import gettext as _ | |
10 from mercurial import ui | |
11 import common | |
12 import os, select, socket, stat, struct, sys | |
13 | |
6753
ed5ffb2c12f3
repo.status: eliminate list_
Matt Mackall <mpm@selenic.com>
parents:
6239
diff
changeset
|
14 def query(ui, repo, names, match, ignored, clean, unknown=True): |
6239 | 15 sock = socket.socket(socket.AF_UNIX) |
16 sockpath = repo.join('inotify.sock') | |
7024
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
17 try: |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
18 sock.connect(sockpath) |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
19 except socket.error, err: |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
20 if err[0] == "AF_UNIX path too long": |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
21 sockpath = os.readlink(sockpath) |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
22 sock.connect(sockpath) |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
23 else: |
ee308d44ad76
inotify: add client code for long pathname handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6239
diff
changeset
|
24 raise |
6239 | 25 |
26 def genquery(): | |
27 for n in names or []: | |
28 yield n | |
29 states = 'almrx!' | |
6753
ed5ffb2c12f3
repo.status: eliminate list_
Matt Mackall <mpm@selenic.com>
parents:
6239
diff
changeset
|
30 if ignored: |
6239 | 31 raise ValueError('this is insanity') |
7145
6f4a253f2a64
inotify: fix status not showing "clean" files (issue907)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7027
diff
changeset
|
32 if clean: states += 'c' |
6753
ed5ffb2c12f3
repo.status: eliminate list_
Matt Mackall <mpm@selenic.com>
parents:
6239
diff
changeset
|
33 if unknown: states += '?' |
6239 | 34 yield states |
35 | |
36 req = '\0'.join(genquery()) | |
37 | |
38 sock.sendall(chr(common.version)) | |
39 sock.sendall(req) | |
40 sock.shutdown(socket.SHUT_WR) | |
41 | |
42 cs = common.recvcs(sock) | |
43 version = ord(cs.read(1)) | |
44 | |
45 if version != common.version: | |
46 ui.warn(_('(inotify: received response from incompatible server ' | |
47 'version %d)\n') % version) | |
48 return None | |
49 | |
50 try: | |
51 resphdr = struct.unpack(common.resphdrfmt, cs.read(common.resphdrsize)) | |
52 except struct.error: | |
53 return None | |
54 | |
55 def readnames(nbytes): | |
56 if nbytes: | |
57 names = cs.read(nbytes) | |
58 if names: | |
59 return filter(match, names.split('\0')) | |
60 return [] | |
61 | |
62 return map(readnames, resphdr) |