diff --git a/hgext/inotify/client.py b/hgext/inotify/client.py --- a/hgext/inotify/client.py +++ b/hgext/inotify/client.py @@ -46,8 +46,12 @@ def query(ui, repo, names, match, ignore 'version %d)\n') % version) return None + # only one type of request is supported for now + type = 'STAT' + hdrfmt = common.resphdrfmts[type] + hdrsize = common.resphdrsizes[type] try: - resphdr = struct.unpack(common.resphdrfmt, cs.read(common.resphdrsize)) + resphdr = struct.unpack(hdrfmt, cs.read(hdrsize)) except struct.error: return None diff --git a/hgext/inotify/common.py b/hgext/inotify/common.py --- a/hgext/inotify/common.py +++ b/hgext/inotify/common.py @@ -10,8 +10,11 @@ import cStringIO, socket, struct version = 1 -resphdrfmt = '>llllllll' -resphdrsize = struct.calcsize(resphdrfmt) +resphdrfmts = { + 'STAT': '>llllllll' # status requests +} +resphdrsizes = dict((k, struct.calcsize(v)) + for k, v in resphdrfmts.iteritems()) def recvcs(sock): cs = cStringIO.StringIO() diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py --- a/hgext/inotify/server.py +++ b/hgext/inotify/server.py @@ -589,8 +589,6 @@ class server(object): cs = common.recvcs(sock) version = ord(cs.read(1)) - sock.sendall(chr(common.version)) - if version != common.version: self.ui.warn(_('received query from incompatible client ' 'version %d\n') % version) @@ -638,7 +636,9 @@ class server(object): try: try: - sock.sendall(struct.pack(common.resphdrfmt, + v = chr(common.version) + + sock.sendall(v + struct.pack(common.resphdrfmts['STAT'], *map(len, results))) sock.sendall(''.join(results)) finally: