Mercurial > hg
changeset 11621:e46a8b2331a6
protocol: shuffle server methods to group send methods
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 16 Jul 2010 18:16:15 +0200 |
parents | 86b49e0083a7 |
children | 1d48681b17a4 |
files | mercurial/hgweb/protocol.py mercurial/sshserver.py |
diffstat | 2 files changed, 20 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/protocol.py Fri Jul 16 23:02:46 2010 +0200 +++ b/mercurial/hgweb/protocol.py Fri Jul 16 18:16:15 2010 +0200 @@ -28,6 +28,16 @@ else: data[k] = self.req.form[k][0] return [data[k] for k in keys] + def getfile(self, fp): + length = int(self.req.env['CONTENT_LENGTH']) + for s in util.filechunkiter(self.req, limit=length): + fp.write(s) + def redirect(self): + self.oldio = sys.stdout, sys.stderr + sys.stderr = sys.stdout = cStringIO.StringIO() + def respond(self, s): + self.req.respond(HTTP_OK, HGTYPE, length=len(s)) + self.response = s def sendchangegroup(self, cg): self.req.respond(HTTP_OK, HGTYPE) z = zlib.compressobj() @@ -41,16 +51,6 @@ self.req.respond(HTTP_OK, HGTYPE) for chunk in source: self.req.write(chunk) - def respond(self, s): - self.req.respond(HTTP_OK, HGTYPE, length=len(s)) - self.response = s - def getfile(self, fp): - length = int(self.req.env['CONTENT_LENGTH']) - for s in util.filechunkiter(self.req, limit=length): - fp.write(s) - def redirect(self): - self.oldio = sys.stdout, sys.stderr - sys.stderr = sys.stdout = cStringIO.StringIO() def respondpush(self, ret): val = sys.stdout.getvalue() sys.stdout, sys.stderr = self.oldio
--- a/mercurial/sshserver.py Fri Jul 16 23:02:46 2010 +0200 +++ b/mercurial/sshserver.py Fri Jul 16 18:16:15 2010 +0200 @@ -49,6 +49,16 @@ def getarg(self, name): return self.getargs(name)[0] + def getfile(self, fpout): + self.respond('') + count = int(self.fin.readline()) + while count: + fpout.write(self.fin.read(count)) + count = int(self.fin.readline()) + + def redirect(self): + pass + def respond(self, v): self.fout.write("%d\n" % len(v)) self.fout.write(v) @@ -68,16 +78,6 @@ self.fout.write(chunk) self.fout.flush() - def getfile(self, fpout): - self.respond('') - count = int(self.fin.readline()) - while count: - fpout.write(self.fin.read(count)) - count = int(self.fin.readline()) - - def redirect(self): - pass - def respondpush(self, ret): self.respond('') self.respond(str(ret))