##// END OF EJS Templates
inotify: Abstract the layer format and sizes to a inotify.common dictionary...
Nicolas Dumazet -
r8386:4aad9821 default
parent child Browse files
Show More
@@ -46,8 +46,12 b' def query(ui, repo, names, match, ignore'
46 'version %d)\n') % version)
46 'version %d)\n') % version)
47 return None
47 return None
48
48
49 # only one type of request is supported for now
50 type = 'STAT'
51 hdrfmt = common.resphdrfmts[type]
52 hdrsize = common.resphdrsizes[type]
49 try:
53 try:
50 resphdr = struct.unpack(common.resphdrfmt, cs.read(common.resphdrsize))
54 resphdr = struct.unpack(hdrfmt, cs.read(hdrsize))
51 except struct.error:
55 except struct.error:
52 return None
56 return None
53
57
@@ -10,8 +10,11 b' import cStringIO, socket, struct'
10
10
11 version = 1
11 version = 1
12
12
13 resphdrfmt = '>llllllll'
13 resphdrfmts = {
14 resphdrsize = struct.calcsize(resphdrfmt)
14 'STAT': '>llllllll' # status requests
15 }
16 resphdrsizes = dict((k, struct.calcsize(v))
17 for k, v in resphdrfmts.iteritems())
15
18
16 def recvcs(sock):
19 def recvcs(sock):
17 cs = cStringIO.StringIO()
20 cs = cStringIO.StringIO()
@@ -589,8 +589,6 b' class server(object):'
589 cs = common.recvcs(sock)
589 cs = common.recvcs(sock)
590 version = ord(cs.read(1))
590 version = ord(cs.read(1))
591
591
592 sock.sendall(chr(common.version))
593
594 if version != common.version:
592 if version != common.version:
595 self.ui.warn(_('received query from incompatible client '
593 self.ui.warn(_('received query from incompatible client '
596 'version %d\n') % version)
594 'version %d\n') % version)
@@ -638,7 +636,9 b' class server(object):'
638
636
639 try:
637 try:
640 try:
638 try:
641 sock.sendall(struct.pack(common.resphdrfmt,
639 v = chr(common.version)
640
641 sock.sendall(v + struct.pack(common.resphdrfmts['STAT'],
642 *map(len, results)))
642 *map(len, results)))
643 sock.sendall(''.join(results))
643 sock.sendall(''.join(results))
644 finally:
644 finally:
General Comments 0
You need to be logged in to leave comments. Login now