Mercurial > hg
changeset 11594:67863f9d805f
protocol: unify server-side capabilities functions
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 15 Jul 2010 13:56:52 -0500 |
parents | d054cc5c7737 |
children | 368cd5325348 |
files | mercurial/hgweb/protocol.py mercurial/sshserver.py mercurial/wireproto.py |
diffstat | 3 files changed, 19 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/protocol.py Thu Jul 15 11:24:42 2010 -0500 +++ b/mercurial/hgweb/protocol.py Thu Jul 15 13:56:52 2010 -0500 @@ -21,14 +21,3 @@ ] HGTYPE = 'application/mercurial-0.1' -basecaps = 'lookup changegroupsubset branchmap pushkey'.split() - -def capabilities(repo, req): - caps = copy.copy(basecaps) - if streamclone.allowed(repo.ui): - caps.append('stream=%d' % repo.changelog.version) - if changegroupmod.bundlepriority: - caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) - rsp = ' '.join(caps) - req.respond(HTTP_OK, HGTYPE, length=len(rsp)) - yield rsp
--- a/mercurial/sshserver.py Thu Jul 15 11:24:42 2010 -0500 +++ b/mercurial/sshserver.py Thu Jul 15 13:56:52 2010 -0500 @@ -12,9 +12,6 @@ import os, sys, tempfile, urllib, copy class sshserver(object): - - caps = 'unbundle lookup changegroupsubset branchmap pushkey'.split() - def __init__(self, ui, repo): self.ui = ui self.repo = repo @@ -106,19 +103,6 @@ else: self.respond("") return cmd != '' - def do_hello(self): - '''the hello command returns a set of lines describing various - interesting things about the server, in an RFC822-like format. - Currently the only one defined is "capabilities", which - consists of a line in the form: - - capabilities: space separated list of tokens - ''' - caps = copy.copy(self.caps) - if streamclone.allowed(self.repo.ui): - caps.append('stream=%d' % self.repo.changelog.version) - return "capabilities: %s\n" % (' '.join(caps),) - def do_lock(self): '''DEPRECATED - allowing remote client to lock repo is not safe'''
--- a/mercurial/wireproto.py Thu Jul 15 11:24:42 2010 -0500 +++ b/mercurial/wireproto.py Thu Jul 15 13:56:52 2010 -0500 @@ -159,6 +159,13 @@ r.append(" ".join(map(hex, b)) + "\n") return "".join(r) +def capabilities(repo, proto): + caps = 'lookup changegroupsubset branchmap pushkey'.split() + if streamclone.allowed(repo.ui): + caps.append('stream=%d' % repo.changelog.version) + caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) + return ' '.join(caps) + def changegroup(repo, proto, roots): nodes = map(bin, roots.split(" ")) cg = repo.changegroup(nodes, 'serve') @@ -174,6 +181,16 @@ h = repo.heads() return " ".join(map(hex, h)) + "\n" +def hello(repo, proto): + '''the hello command returns a set of lines describing various + interesting things about the server, in an RFC822-like format. + Currently the only one defined is "capabilities", which + consists of a line in the form: + + capabilities: space separated list of tokens + ''' + return "capabilities: %s\n" % (capabilities(repo, proto)) + def listkeys(repo, proto, namespace): d = pushkey_.list(repo, namespace).items() t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), @@ -253,9 +270,11 @@ 'between': (between, 'pairs'), 'branchmap': (branchmap, ''), 'branches': (branches, 'nodes'), + 'capabilities': (capabilities, ''), 'changegroup': (changegroup, 'roots'), 'changegroupsubset': (changegroupsubset, 'bases heads'), 'heads': (heads, ''), + 'hello': (hello, ''), 'listkeys': (listkeys, 'namespace'), 'lookup': (lookup, 'key'), 'pushkey': (pushkey, 'namespace key old new'),