# HG changeset patch # User Matt Mackall # Date 1276722313 18000 # Node ID 02a4373ca5cdf7c11d2fbae138567a5f88f831fe # Parent b9eb005c54addbda6d58161f3261046c3d04ae53 pushkey: add ssh support diff -r b9eb005c54ad -r 02a4373ca5cd mercurial/sshrepo.py --- a/mercurial/sshrepo.py Wed Jun 16 16:04:46 2010 -0500 +++ b/mercurial/sshrepo.py Wed Jun 16 16:05:13 2010 -0500 @@ -273,4 +273,21 @@ def stream_out(self): return self.do_cmd('stream_out') + def pushkey(self, namespace, key, old, new): + if not self.capable('pushkey'): + return False + d = self.call("pushkey", + namespace=namespace, key=key, old=old, new=new) + return bool(int(d)) + + def listkeys(self, namespace): + if not self.capable('pushkey'): + return {} + d = self.call("listkeys", namespace=namespace) + r = {} + for l in d.splitlines(): + k, v = l.split('\t') + r[k.decode('string-escape')] = v.decode('string-escape') + return r + instance = sshrepository diff -r b9eb005c54ad -r 02a4373ca5cd mercurial/sshserver.py --- a/mercurial/sshserver.py Wed Jun 16 16:04:46 2010 -0500 +++ b/mercurial/sshserver.py Wed Jun 16 16:05:13 2010 -0500 @@ -8,12 +8,12 @@ from i18n import _ from node import bin, hex -import streamclone, util, hook +import streamclone, util, hook, pushkey import os, sys, tempfile, urllib, copy class sshserver(object): - caps = 'unbundle lookup changegroupsubset branchmap'.split() + caps = 'unbundle lookup changegroupsubset branchmap pushkey'.split() def __init__(self, ui, repo): self.ui = ui @@ -223,3 +223,18 @@ except streamclone.StreamException, inst: self.fout.write(str(inst)) self.fout.flush() + + def do_pushkey(self): + arg, key = self.getarg() + arg, namespace = self.getarg() + arg, new = self.getarg() + arg, old = self.getarg() + r = pushkey.push(self.repo, namespace, key, old, new) + self.respond('%s\n' % int(r)) + + def do_listkeys(self): + arg, namespace = self.getarg() + d = pushkey.list(self.repo, namespace).items() + t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), + v.encode('string-escape')) for k, v in d]) + self.respond(t)