changeset 3446:0b450267cf47

Adding changegroupsubset and lookup to ssh protocol so pull -r and clone -r can be supported.
author Eric Hopper <hopper@omnifarious.org>
date Sat, 09 Sep 2006 18:25:06 -0700
parents 233c733e4af5
children ef1032c223e7
files mercurial/sshrepo.py mercurial/sshserver.py
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshrepo.py	Wed Oct 18 02:08:36 2006 -0500
+++ b/mercurial/sshrepo.py	Sat Sep 09 18:25:06 2006 -0700
@@ -131,6 +131,13 @@
     def unlock(self):
         self.call("unlock")
 
+    def lookup(self, key):
+        d = self.call("lookup", key=key)
+        try:
+            return bin(d[:-1])
+        except:
+            raise hg.RepoError("unexpected response '%s'" % (d[:400] + "..."))
+
     def heads(self):
         d = self.call("heads")
         try:
@@ -160,6 +167,11 @@
         n = " ".join(map(hex, nodes))
         return self.do_cmd("changegroup", roots=n)
 
+    def changegroupsubset(self, bases, heads, kind):
+        bases = " ".join(map(hex, bases))
+        heads = " ".join(map(hex, heads))
+        return self.do_cmd("changegroupsubset", bases=bases, heads=heads)
+
     def unbundle(self, cg, heads, source):
         d = self.call("unbundle", heads=' '.join(map(hex, heads)))
         if d:
--- a/mercurial/sshserver.py	Wed Oct 18 02:08:36 2006 -0500
+++ b/mercurial/sshserver.py	Sat Sep 09 18:25:06 2006 -0700
@@ -48,6 +48,11 @@
             else: self.respond("")
         return cmd != ''
 
+    def do_lookup(self):
+        arg, key = self.getarg()
+        assert arg == 'key'
+        self.respond(hex(self.repo.lookup(key)) + "\n")
+
     def do_heads(self):
         h = self.repo.heads()
         self.respond(" ".join(map(hex, h)) + "\n")
@@ -61,7 +66,7 @@
         capabilities: space separated list of tokens
         '''
 
-        caps = ['unbundle']
+        caps = ['unbundle', 'lookup', 'changegroupsubset']
         if self.ui.configbool('server', 'uncompressed'):
             caps.append('stream=%d' % self.repo.revlogversion)
         self.respond("capabilities: %s\n" % (' '.join(caps),))
@@ -110,6 +115,22 @@
 
         self.fout.flush()
 
+    def do_changegroupsubset(self):
+        bases = []
+        heads = []
+        argmap = dict([self.getarg(), self.getarg()])
+        bases = [bin(n) for n in argmap['bases'].split(' ')]
+        heads = [bin(n) for n in argmap['heads'].split(' ')]
+
+        cg = self.repo.changegroupsubset(bases, heads, 'serve')
+        while True:
+            d = cg.read(4096)
+            if not d:
+                break
+            self.fout.write(d)
+
+        self.fout.flush()
+
     def do_addchangegroup(self):
         '''DEPRECATED'''