##// END OF EJS Templates
mercurial: implement diff and join for dicts...
mercurial: implement diff and join for dicts Given two dicts, diff returns a dict containing all the keys that are present in one dict but not the other, or whose values are different between the dicts. The values are pairs of the values from the dicts, with missing values being represented as an optional argument, defaulting to None. Given two dicts, join performs what is known as an outer join in relational database land: it returns a dict containing all the keys across both dicts. The values are pairs as above, except they aren't compared to see if they're the same.

File last commit:

r10263:25e57239 stable
r18820:a45e44d7 default
Show More
common.py
53 lines | 1.5 KiB | text/x-python | PythonLexer
Bryan O'Sullivan
Add inotify extension
r6239 # server.py - inotify common protocol code
#
# 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
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Bryan O'Sullivan
Add inotify extension
r6239
import cStringIO, socket, struct
Nicolas Dumazet
inotify: change protocol so that different query types can be supported.
r8553 """
Protocol between inotify clients and server:
Client sending query:
1) send protocol version number
2) send query type (string, 4 letters long)
3) send query parameters:
- For STAT, N+1 \0-separated strings:
1) N different names that need checking
2) 1 string containing all the status types to match
Nicolas Dumazet
inotify: introduce debuginotify, which lists which paths are under watch
r8555 - No parameter needed for DBUG
Nicolas Dumazet
inotify: change protocol so that different query types can be supported.
r8553
Server sending query answer:
1) send protocol version number
2) send query type
3) send struct.pack'ed headers describing the length of the content:
Nicolas Dumazet
inotify: mark directories visited during lookup (issue1844)...
r9854 e.g. for STAT, receive 9 integers describing the length of the
9 \0-separated string lists to be read:
* one file list for each lmar!?ic status type
* one list containing the directories visited during lookup
Nicolas Dumazet
inotify: change protocol so that different query types can be supported.
r8553
"""
Nicolas Dumazet
inotify: mark directories visited during lookup (issue1844)...
r9854 version = 3
Bryan O'Sullivan
Add inotify extension
r6239
Nicolas Dumazet
inotify: Abstract the layer format and sizes to a inotify.common dictionary...
r8386 resphdrfmts = {
Nicolas Dumazet
inotify: mark directories visited during lookup (issue1844)...
r9854 'STAT': '>lllllllll', # status requests
'DBUG': '>l' # debugging queries
Nicolas Dumazet
inotify: Abstract the layer format and sizes to a inotify.common dictionary...
r8386 }
resphdrsizes = dict((k, struct.calcsize(v))
for k, v in resphdrfmts.iteritems())
Bryan O'Sullivan
Add inotify extension
r6239
def recvcs(sock):
cs = cStringIO.StringIO()
s = True
try:
while s:
s = sock.recv(65536)
cs.write(s)
finally:
sock.shutdown(socket.SHUT_RD)
cs.seek(0)
return cs