changeset 826:bee5e1105e6c

exchange: add the pullmarker wireproto command to simple4server This will allow simple server side support. (yes, code duplication is bad I already told you I won't do it too much mom)
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 28 Feb 2014 13:45:59 -0800
parents 7671717afef8
children f62ff54c893b
files hgext/simple4server.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/simple4server.py	Fri Feb 28 13:44:37 2014 -0800
+++ b/hgext/simple4server.py	Fri Feb 28 13:45:59 2014 -0800
@@ -33,13 +33,28 @@
         lock.release()
     return wireproto.pushres(0)
 
+def srv_pullobsmarkers(repo, proto, others):
+    opts = wireproto.options('', ['heads', 'common'], others)
+    for k, v in opts.iteritems():
+        if k in ('heads', 'common'):
+            opts[k] = wireproto.decodelist(v)
+    obsdata = _getobsmarkersstream(repo, **opts)
+    length = '%20i' % len(obsdata.getvalue())
+    def data():
+        yield length
+        for c in proto.groupchunks(obsdata):
+            yield c
+    return wireproto.streamres(data())
+
 def capabilities(orig, repo, proto):
     """wrapper to advertise new capability"""
     caps = orig(repo, proto)
     if obsolete._enabled:
         caps += ' _evoext_pushobsmarkers_0'
+        caps += ' _evoext_pullobsmarkers_0'
     return caps
 
 def extsetup(ui):
     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
+    wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')
     extensions.wrapfunction(wireproto, 'capabilities', capabilities)