##// END OF EJS Templates
fix conflicting variables when no native osutil is available...
fix conflicting variables when no native osutil is available thanks weijun for the bug report and patch, fix issue1309

File last commit:

r7027:ab570692 merge default
r7057:094af6ee default
Show More
client.py
62 lines | 1.7 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>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
from mercurial.i18n import gettext as _
from mercurial import ui
import common
import os, select, socket, stat, struct, sys
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():
for n in names or []:
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')
Matt Mackall
repo.status: eliminate list_
r6753 if clean: states += 'n'
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
try:
resphdr = struct.unpack(common.resphdrfmt, cs.read(common.resphdrsize))
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)