##// END OF EJS Templates
wireproto: make a number of commands batchable...
Peter Arrenbrecht -
r14623:e7c9fdbb default
parent child Browse files
Show More
@@ -161,31 +161,42 b' class wirerepository(repo.repository):'
161 161 def _submitone(self, op, args):
162 162 return self._call(op, **args)
163 163
164 @batchable
164 165 def lookup(self, key):
165 166 self.requirecap('lookup', _('look up remote revision'))
166 d = self._call("lookup", key=encoding.fromlocal(key))
167 f = future()
168 yield todict(key=encoding.fromlocal(key)), f
169 d = f.value
167 170 success, data = d[:-1].split(" ", 1)
168 171 if int(success):
169 return bin(data)
172 yield bin(data)
170 173 self._abort(error.RepoError(data))
171 174
175 @batchable
172 176 def heads(self):
173 d = self._call("heads")
177 f = future()
178 yield {}, f
179 d = f.value
174 180 try:
175 return decodelist(d[:-1])
181 yield decodelist(d[:-1])
176 182 except ValueError:
177 183 self._abort(error.ResponseError(_("unexpected response:"), d))
178 184
185 @batchable
179 186 def known(self, nodes):
180 n = encodelist(nodes)
181 d = self._call("known", nodes=n)
187 f = future()
188 yield todict(nodes=encodelist(nodes)), f
189 d = f.value
182 190 try:
183 return [bool(int(f)) for f in d]
191 yield [bool(int(f)) for f in d]
184 192 except ValueError:
185 193 self._abort(error.ResponseError(_("unexpected response:"), d))
186 194
195 @batchable
187 196 def branchmap(self):
188 d = self._call("branchmap")
197 f = future()
198 yield {}, f
199 d = f.value
189 200 try:
190 201 branchmap = {}
191 202 for branchpart in d.splitlines():
@@ -193,7 +204,7 b' class wirerepository(repo.repository):'
193 204 branchname = encoding.tolocal(urllib.unquote(branchname))
194 205 branchheads = decodelist(branchheads)
195 206 branchmap[branchname] = branchheads
196 return branchmap
207 yield branchmap
197 208 except TypeError:
198 209 self._abort(error.ResponseError(_("unexpected response:"), d))
199 210
@@ -218,30 +229,35 b' class wirerepository(repo.repository):'
218 229 self._abort(error.ResponseError(_("unexpected response:"), d))
219 230 return r
220 231
232 @batchable
221 233 def pushkey(self, namespace, key, old, new):
222 234 if not self.capable('pushkey'):
223 return False
224 d = self._call("pushkey",
225 namespace=encoding.fromlocal(namespace),
226 key=encoding.fromlocal(key),
227 old=encoding.fromlocal(old),
228 new=encoding.fromlocal(new))
235 yield False, None
236 f = future()
237 yield todict(namespace=encoding.fromlocal(namespace),
238 key=encoding.fromlocal(key),
239 old=encoding.fromlocal(old),
240 new=encoding.fromlocal(new)), f
241 d = f.value
229 242 try:
230 243 d = bool(int(d))
231 244 except ValueError:
232 245 raise error.ResponseError(
233 246 _('push failed (unexpected response):'), d)
234 return d
247 yield d
235 248
249 @batchable
236 250 def listkeys(self, namespace):
237 251 if not self.capable('pushkey'):
238 return {}
239 d = self._call("listkeys", namespace=encoding.fromlocal(namespace))
252 yield {}, None
253 f = future()
254 yield todict(namespace=encoding.fromlocal(namespace)), f
255 d = f.value
240 256 r = {}
241 257 for l in d.splitlines():
242 258 k, v = l.split('\t')
243 259 r[encoding.tolocal(k)] = encoding.tolocal(v)
244 return r
260 yield r
245 261
246 262 def stream_out(self):
247 263 return self._callstream('stream_out')
General Comments 0
You need to be logged in to leave comments. Login now