hgext/inotify/common.py
author Greg Ward <greg-hg@gerg.ca>
Thu, 07 May 2009 21:35:12 -0400
changeset 8308 1268b895f69b
parent 8225 46293a0c7e9f
child 8386 4aad982111b6
permissions -rw-r--r--
test-convert-bzr: tweak sed hack to preserve timezone in 'bzr log' output

# 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 version 2, 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