Mercurial > public > mercurial-scm > hg-stable
diff mercurial/sshserver.py @ 11625:cdeb861335d5
protocol: wrap non-string protocol responses in classes
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Tue, 20 Jul 2010 20:53:33 +0200 |
parents | 31d0a6d50ee2 |
children | c327bfa5e831 |
line wrap: on
line diff
--- a/mercurial/sshserver.py Fri Jul 16 22:20:19 2010 +0200 +++ b/mercurial/sshserver.py Tue Jul 20 20:53:33 2010 +0200 @@ -72,13 +72,13 @@ self.fout.flush() def sendstream(self, source): - for chunk in source: + for chunk in source.gen: self.fout.write(chunk) self.fout.flush() - def sendpushresponse(self, ret): + def sendpushresponse(self, rsp): self.sendresponse('') - self.sendresponse(str(ret)) + self.sendresponse(str(rsp.res)) def serve_forever(self): try: @@ -89,10 +89,17 @@ self.lock.release() sys.exit(0) + handlers = { + str: sendresponse, + wireproto.streamres: sendstream, + wireproto.pushres: sendpushresponse, + } + def serve_one(self): cmd = self.fin.readline()[:-1] if cmd and cmd in wireproto.commands: - wireproto.dispatch(self.repo, self, cmd) + rsp = wireproto.dispatch(self.repo, self, cmd) + self.handlers[rsp.__class__](self, rsp) elif cmd: impl = getattr(self, 'do_' + cmd, None) if impl: