##// END OF EJS Templates
mq: new method invalidate...
mq: new method invalidate Introduce method invalidate (similar to dirstate and repo).

File last commit:

r8386:4aad9821 default
r8525:b169ba60 default
Show More
client.py
65 lines | 1.8 KiB | text/x-python | PythonLexer
Bryan O'Sullivan
Add inotify extension
r6239 # client.py - inotify status client
#
# Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com>
# Copyright 2007, 2008 Brendan Cully <brendan@kublai.com>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.
Bryan O'Sullivan
Add inotify extension
r6239
Martin Geisler
i18n: import _ instead of gettext
r7225 from mercurial.i18n import _
Bryan O'Sullivan
Add inotify extension
r6239 import common
Benoit Boissinot
remove unused variables
r7280 import os, socket, struct
Bryan O'Sullivan
Add inotify extension
r6239
Matt Mackall
repo.status: eliminate list_
r6753 def query(ui, repo, names, match, ignored, clean, unknown=True):
Bryan O'Sullivan
Add inotify extension
r6239 sock = socket.socket(socket.AF_UNIX)
sockpath = repo.join('inotify.sock')
Benoit Boissinot
inotify: add client code for long pathname handling
r7024 try:
sock.connect(sockpath)
except socket.error, err:
if err[0] == "AF_UNIX path too long":
sockpath = os.readlink(sockpath)
sock.connect(sockpath)
else:
raise
Bryan O'Sullivan
Add inotify extension
r6239
def genquery():
Nicolas Dumazet
inotify: files is always a list: 'files or []' is redundant...
r8067 for n in names:
Bryan O'Sullivan
Add inotify extension
r6239 yield n
states = 'almrx!'
Matt Mackall
repo.status: eliminate list_
r6753 if ignored:
Bryan O'Sullivan
Add inotify extension
r6239 raise ValueError('this is insanity')
Benoit Boissinot
inotify: fix status not showing "clean" files (issue907)...
r7145 if clean: states += 'c'
Matt Mackall
repo.status: eliminate list_
r6753 if unknown: states += '?'
Bryan O'Sullivan
Add inotify extension
r6239 yield states
req = '\0'.join(genquery())
sock.sendall(chr(common.version))
sock.sendall(req)
sock.shutdown(socket.SHUT_WR)
cs = common.recvcs(sock)
version = ord(cs.read(1))
if version != common.version:
ui.warn(_('(inotify: received response from incompatible server '
'version %d)\n') % version)
return None
Nicolas Dumazet
inotify: Abstract the layer format and sizes to a inotify.common dictionary...
r8386 # only one type of request is supported for now
type = 'STAT'
hdrfmt = common.resphdrfmts[type]
hdrsize = common.resphdrsizes[type]
Bryan O'Sullivan
Add inotify extension
r6239 try:
Nicolas Dumazet
inotify: Abstract the layer format and sizes to a inotify.common dictionary...
r8386 resphdr = struct.unpack(hdrfmt, cs.read(hdrsize))
Bryan O'Sullivan
Add inotify extension
r6239 except struct.error:
return None
def readnames(nbytes):
if nbytes:
names = cs.read(nbytes)
if names:
return filter(match, names.split('\0'))
return []
return map(readnames, resphdr)