diff hgext/inotify/common.py @ 6239:39cfcef4f463

Add inotify extension
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 12 Mar 2008 15:30:11 -0700
parents
children 46293a0c7e9f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgext/inotify/common.py	Wed Mar 12 15:30:11 2008 -0700
@@ -0,0 +1,26 @@
+# 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