mercurial/hgweb/hgweb_mod.py
changeset 11584 1af96b090116
parent 11582 26c7d4fc31bf
child 11585 5d907fbb9703
equal deleted inserted replaced
11583:944c23762c3c 11584:1af96b090116
     4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     5 #
     5 #
     6 # This software may be used and distributed according to the terms of the
     6 # This software may be used and distributed according to the terms of the
     7 # GNU General Public License version 2 or any later version.
     7 # GNU General Public License version 2 or any later version.
     8 
     8 
     9 import os
     9 import os, zlib
    10 from mercurial import ui, hg, hook, error, encoding, templater, wireproto
    10 from mercurial import ui, hg, hook, error, encoding, templater, wireproto
    11 from common import get_mtime, ErrorResponse, permhooks
    11 from common import get_mtime, ErrorResponse, permhooks
    12 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    12 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    13 from request import wsgirequest
    13 from request import wsgirequest
    14 import webcommands, protocol, webutil
    14 import webcommands, protocol, webutil
    20     'listkeys': 'pull',
    20     'listkeys': 'pull',
    21     'unbundle': 'push',
    21     'unbundle': 'push',
    22     'pushkey': 'push',
    22     'pushkey': 'push',
    23 }
    23 }
    24 
    24 
       
    25 HGTYPE = 'application/mercurial-0.1'
    25 class webproto(object):
    26 class webproto(object):
    26     def __init__(self, req):
    27     def __init__(self, req):
    27         self.req = req
    28         self.req = req
    28         self.response = ''
    29         self.response = ''
    29     def getargs(self, args):
    30     def getargs(self, args):
    37                         star[key] = self.req.form[key][0]
    38                         star[key] = self.req.form[key][0]
    38                 data['*'] = star
    39                 data['*'] = star
    39             else:
    40             else:
    40                 data[k] = self.req.form[k][0]
    41                 data[k] = self.req.form[k][0]
    41         return [data[k] for k in keys]
    42         return [data[k] for k in keys]
       
    43     def sendchangegroup(self, cg):
       
    44         self.req.respond(HTTP_OK, HGTYPE)
       
    45         z = zlib.compressobj()
       
    46         while 1:
       
    47             chunk = cg.read(4096)
       
    48             if not chunk:
       
    49                 break
       
    50             self.req.write(z.compress(chunk))
       
    51         self.req.write(z.flush())
       
    52 
    42     def respond(self, s):
    53     def respond(self, s):
    43         HGTYPE = 'application/mercurial-0.1'
       
    44         self.req.respond(HTTP_OK, HGTYPE, length=len(s))
    54         self.req.respond(HTTP_OK, HGTYPE, length=len(s))
    45         self.response = s
    55         self.response = s
    46 
    56 
    47 def callproto(repo, req, cmd):
    57 def callproto(repo, req, cmd):
    48     p = webproto(req)
    58     p = webproto(req)