hgext/inotify/common.py
author Patrick Mezard <pmezard@gmail.com>
Mon, 13 Apr 2009 16:15:45 +0200
changeset 8063 ee8d9b93b316
parent 6239 39cfcef4f463
child 8225 46293a0c7e9f
permissions -rw-r--r--
convert/p4: win32 fixes * cmd.exe does not know single quotes * win32 does not like trailing whitespace very much. Trade test coverage for maintenance time and drop the trailing whitespaces tests.

# server.py - inotify common protocol code
#
# 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.

import cStringIO, socket, struct

version = 1

resphdrfmt = '>llllllll'
resphdrsize = struct.calcsize(resphdrfmt)

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