##// END OF EJS Templates
protocol: unify server-side capabilities functions
Matt Mackall -
r11594:67863f9d default
parent child Browse files
Show More
@@ -21,14 +21,3 from common import ErrorResponse, HTTP_O
21 21 ]
22 22
23 23 HGTYPE = 'application/mercurial-0.1'
24 basecaps = 'lookup changegroupsubset branchmap pushkey'.split()
25
26 def capabilities(repo, req):
27 caps = copy.copy(basecaps)
28 if streamclone.allowed(repo.ui):
29 caps.append('stream=%d' % repo.changelog.version)
30 if changegroupmod.bundlepriority:
31 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
32 rsp = ' '.join(caps)
33 req.respond(HTTP_OK, HGTYPE, length=len(rsp))
34 yield rsp
@@ -12,9 +12,6 import streamclone, util, hook, pushkey,
12 12 import os, sys, tempfile, urllib, copy
13 13
14 14 class sshserver(object):
15
16 caps = 'unbundle lookup changegroupsubset branchmap pushkey'.split()
17
18 15 def __init__(self, ui, repo):
19 16 self.ui = ui
20 17 self.repo = repo
@@ -106,19 +103,6 class sshserver(object):
106 103 else: self.respond("")
107 104 return cmd != ''
108 105
109 def do_hello(self):
110 '''the hello command returns a set of lines describing various
111 interesting things about the server, in an RFC822-like format.
112 Currently the only one defined is "capabilities", which
113 consists of a line in the form:
114
115 capabilities: space separated list of tokens
116 '''
117 caps = copy.copy(self.caps)
118 if streamclone.allowed(self.repo.ui):
119 caps.append('stream=%d' % self.repo.changelog.version)
120 return "capabilities: %s\n" % (' '.join(caps),)
121
122 106 def do_lock(self):
123 107 '''DEPRECATED - allowing remote client to lock repo is not safe'''
124 108
@@ -159,6 +159,13 def branches(repo, proto, nodes):
159 159 r.append(" ".join(map(hex, b)) + "\n")
160 160 return "".join(r)
161 161
162 def capabilities(repo, proto):
163 caps = 'lookup changegroupsubset branchmap pushkey'.split()
164 if streamclone.allowed(repo.ui):
165 caps.append('stream=%d' % repo.changelog.version)
166 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
167 return ' '.join(caps)
168
162 169 def changegroup(repo, proto, roots):
163 170 nodes = map(bin, roots.split(" "))
164 171 cg = repo.changegroup(nodes, 'serve')
@@ -174,6 +181,16 def heads(repo, proto):
174 181 h = repo.heads()
175 182 return " ".join(map(hex, h)) + "\n"
176 183
184 def hello(repo, proto):
185 '''the hello command returns a set of lines describing various
186 interesting things about the server, in an RFC822-like format.
187 Currently the only one defined is "capabilities", which
188 consists of a line in the form:
189
190 capabilities: space separated list of tokens
191 '''
192 return "capabilities: %s\n" % (capabilities(repo, proto))
193
177 194 def listkeys(repo, proto, namespace):
178 195 d = pushkey_.list(repo, namespace).items()
179 196 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'),
@@ -253,9 +270,11 commands = {
253 270 'between': (between, 'pairs'),
254 271 'branchmap': (branchmap, ''),
255 272 'branches': (branches, 'nodes'),
273 'capabilities': (capabilities, ''),
256 274 'changegroup': (changegroup, 'roots'),
257 275 'changegroupsubset': (changegroupsubset, 'bases heads'),
258 276 'heads': (heads, ''),
277 'hello': (hello, ''),
259 278 'listkeys': (listkeys, 'namespace'),
260 279 'lookup': (lookup, 'key'),
261 280 'pushkey': (pushkey, 'namespace key old new'),
General Comments 0
You need to be logged in to leave comments. Login now