##// END OF EJS Templates
wireprotoserver: make some instance attributes private...
Gregory Szorc -
r35888:f1efc0ca default
parent child Browse files
Show More
@@ -248,60 +248,60 def callhttp(repo, req, cmd):
248
248
249 class sshserver(abstractserverproto):
249 class sshserver(abstractserverproto):
250 def __init__(self, ui, repo):
250 def __init__(self, ui, repo):
251 self.ui = ui
251 self._ui = ui
252 self.repo = repo
252 self._repo = repo
253 self.fin = ui.fin
253 self._fin = ui.fin
254 self.fout = ui.fout
254 self._fout = ui.fout
255 self.name = 'ssh'
255 self.name = 'ssh'
256
256
257 hook.redirect(True)
257 hook.redirect(True)
258 ui.fout = repo.ui.fout = ui.ferr
258 ui.fout = repo.ui.fout = ui.ferr
259
259
260 # Prevent insertion/deletion of CRs
260 # Prevent insertion/deletion of CRs
261 util.setbinary(self.fin)
261 util.setbinary(self._fin)
262 util.setbinary(self.fout)
262 util.setbinary(self._fout)
263
263
264 def getargs(self, args):
264 def getargs(self, args):
265 data = {}
265 data = {}
266 keys = args.split()
266 keys = args.split()
267 for n in xrange(len(keys)):
267 for n in xrange(len(keys)):
268 argline = self.fin.readline()[:-1]
268 argline = self._fin.readline()[:-1]
269 arg, l = argline.split()
269 arg, l = argline.split()
270 if arg not in keys:
270 if arg not in keys:
271 raise error.Abort(_("unexpected parameter %r") % arg)
271 raise error.Abort(_("unexpected parameter %r") % arg)
272 if arg == '*':
272 if arg == '*':
273 star = {}
273 star = {}
274 for k in xrange(int(l)):
274 for k in xrange(int(l)):
275 argline = self.fin.readline()[:-1]
275 argline = self._fin.readline()[:-1]
276 arg, l = argline.split()
276 arg, l = argline.split()
277 val = self.fin.read(int(l))
277 val = self._fin.read(int(l))
278 star[arg] = val
278 star[arg] = val
279 data['*'] = star
279 data['*'] = star
280 else:
280 else:
281 val = self.fin.read(int(l))
281 val = self._fin.read(int(l))
282 data[arg] = val
282 data[arg] = val
283 return [data[k] for k in keys]
283 return [data[k] for k in keys]
284
284
285 def getfile(self, fpout):
285 def getfile(self, fpout):
286 self.sendresponse('')
286 self.sendresponse('')
287 count = int(self.fin.readline())
287 count = int(self._fin.readline())
288 while count:
288 while count:
289 fpout.write(self.fin.read(count))
289 fpout.write(self._fin.read(count))
290 count = int(self.fin.readline())
290 count = int(self._fin.readline())
291
291
292 def redirect(self):
292 def redirect(self):
293 pass
293 pass
294
294
295 def sendresponse(self, v):
295 def sendresponse(self, v):
296 self.fout.write("%d\n" % len(v))
296 self._fout.write("%d\n" % len(v))
297 self.fout.write(v)
297 self._fout.write(v)
298 self.fout.flush()
298 self._fout.flush()
299
299
300 def sendstream(self, source):
300 def sendstream(self, source):
301 write = self.fout.write
301 write = self._fout.write
302 for chunk in source.gen:
302 for chunk in source.gen:
303 write(chunk)
303 write(chunk)
304 self.fout.flush()
304 self._fout.flush()
305
305
306 def sendpushresponse(self, rsp):
306 def sendpushresponse(self, rsp):
307 self.sendresponse('')
307 self.sendresponse('')
@@ -311,10 +311,10 class sshserver(abstractserverproto):
311 self.sendresponse(rsp.res)
311 self.sendresponse(rsp.res)
312
312
313 def sendooberror(self, rsp):
313 def sendooberror(self, rsp):
314 self.ui.ferr.write('%s\n-\n' % rsp.message)
314 self._ui.ferr.write('%s\n-\n' % rsp.message)
315 self.ui.ferr.flush()
315 self._ui.ferr.flush()
316 self.fout.write('\n')
316 self._fout.write('\n')
317 self.fout.flush()
317 self._fout.flush()
318
318
319 def serve_forever(self):
319 def serve_forever(self):
320 while self.serve_one():
320 while self.serve_one():
@@ -331,9 +331,9 class sshserver(abstractserverproto):
331 }
331 }
332
332
333 def serve_one(self):
333 def serve_one(self):
334 cmd = self.fin.readline()[:-1]
334 cmd = self._fin.readline()[:-1]
335 if cmd and cmd in wireproto.commands:
335 if cmd and cmd in wireproto.commands:
336 rsp = wireproto.dispatch(self.repo, self, cmd)
336 rsp = wireproto.dispatch(self._repo, self, cmd)
337 self.handlers[rsp.__class__](self, rsp)
337 self.handlers[rsp.__class__](self, rsp)
338 elif cmd:
338 elif cmd:
339 self.sendresponse("")
339 self.sendresponse("")
General Comments 0
You need to be logged in to leave comments. Login now