##// 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 b' from common import ErrorResponse, HTTP_O'
21 ]
21 ]
22
22
23 HGTYPE = 'application/mercurial-0.1'
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 b' import streamclone, util, hook, pushkey,'
12 import os, sys, tempfile, urllib, copy
12 import os, sys, tempfile, urllib, copy
13
13
14 class sshserver(object):
14 class sshserver(object):
15
16 caps = 'unbundle lookup changegroupsubset branchmap pushkey'.split()
17
18 def __init__(self, ui, repo):
15 def __init__(self, ui, repo):
19 self.ui = ui
16 self.ui = ui
20 self.repo = repo
17 self.repo = repo
@@ -106,19 +103,6 b' class sshserver(object):'
106 else: self.respond("")
103 else: self.respond("")
107 return cmd != ''
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 def do_lock(self):
106 def do_lock(self):
123 '''DEPRECATED - allowing remote client to lock repo is not safe'''
107 '''DEPRECATED - allowing remote client to lock repo is not safe'''
124
108
@@ -159,6 +159,13 b' def branches(repo, proto, nodes):'
159 r.append(" ".join(map(hex, b)) + "\n")
159 r.append(" ".join(map(hex, b)) + "\n")
160 return "".join(r)
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 def changegroup(repo, proto, roots):
169 def changegroup(repo, proto, roots):
163 nodes = map(bin, roots.split(" "))
170 nodes = map(bin, roots.split(" "))
164 cg = repo.changegroup(nodes, 'serve')
171 cg = repo.changegroup(nodes, 'serve')
@@ -174,6 +181,16 b' def heads(repo, proto):'
174 h = repo.heads()
181 h = repo.heads()
175 return " ".join(map(hex, h)) + "\n"
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 def listkeys(repo, proto, namespace):
194 def listkeys(repo, proto, namespace):
178 d = pushkey_.list(repo, namespace).items()
195 d = pushkey_.list(repo, namespace).items()
179 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'),
196 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'),
@@ -253,9 +270,11 b' commands = {'
253 'between': (between, 'pairs'),
270 'between': (between, 'pairs'),
254 'branchmap': (branchmap, ''),
271 'branchmap': (branchmap, ''),
255 'branches': (branches, 'nodes'),
272 'branches': (branches, 'nodes'),
273 'capabilities': (capabilities, ''),
256 'changegroup': (changegroup, 'roots'),
274 'changegroup': (changegroup, 'roots'),
257 'changegroupsubset': (changegroupsubset, 'bases heads'),
275 'changegroupsubset': (changegroupsubset, 'bases heads'),
258 'heads': (heads, ''),
276 'heads': (heads, ''),
277 'hello': (hello, ''),
259 'listkeys': (listkeys, 'namespace'),
278 'listkeys': (listkeys, 'namespace'),
260 'lookup': (lookup, 'key'),
279 'lookup': (lookup, 'key'),
261 'pushkey': (pushkey, 'namespace key old new'),
280 'pushkey': (pushkey, 'namespace key old new'),
General Comments 0
You need to be logged in to leave comments. Login now