# HG changeset patch # User Eric Hopper # Date 2006-09-10 01:25:06 # Node ID 0b450267cf472a634ff03362ca7a89b386574f4d # Parent 233c733e4af5391f56aa8947ee2d38937b294f33 Adding changegroupsubset and lookup to ssh protocol so pull -r and clone -r can be supported. diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py --- a/mercurial/sshrepo.py +++ b/mercurial/sshrepo.py @@ -131,6 +131,13 @@ class sshrepository(remoterepository): 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 @@ class sshrepository(remoterepository): 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: diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py --- a/mercurial/sshserver.py +++ b/mercurial/sshserver.py @@ -48,6 +48,11 @@ class sshserver(object): 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 @@ class sshserver(object): 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 @@ class sshserver(object): 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'''