mercurial/hgweb/protocol.py
changeset 9713 d193cc97c4e8
parent 9694 8269fe2d48f6
child 10263 25e572394f5c
equal deleted inserted replaced
9712:18b134ef294c 9713:d193cc97c4e8
     3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2, incorporated herein by reference.
     6 # GNU General Public License version 2, incorporated herein by reference.
     7 
     7 
     8 import cStringIO, zlib, tempfile, errno, os, sys, urllib
     8 import cStringIO, zlib, tempfile, errno, os, sys, urllib, copy
     9 from mercurial import util, streamclone
     9 from mercurial import util, streamclone
    10 from mercurial.node import bin, hex
    10 from mercurial.node import bin, hex
    11 from mercurial import changegroup as changegroupmod
    11 from mercurial import changegroup as changegroupmod
    12 from common import ErrorResponse, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    12 from common import ErrorResponse, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    13 
    13 
    19    'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
    19    'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
    20    'branchmap',
    20    'branchmap',
    21 ]
    21 ]
    22 
    22 
    23 HGTYPE = 'application/mercurial-0.1'
    23 HGTYPE = 'application/mercurial-0.1'
       
    24 basecaps = 'lookup changegroupsubset branchmap'.split()
    24 
    25 
    25 def lookup(repo, req):
    26 def lookup(repo, req):
    26     try:
    27     try:
    27         r = hex(repo.lookup(req.form['key'][0]))
    28         r = hex(repo.lookup(req.form['key'][0]))
    28         success = 1
    29         success = 1
   107         yield z.compress(chunk)
   108         yield z.compress(chunk)
   108 
   109 
   109     yield z.flush()
   110     yield z.flush()
   110 
   111 
   111 def capabilities(repo, req):
   112 def capabilities(repo, req):
   112     caps = ['lookup', 'changegroupsubset', 'branchmap']
   113     caps = copy.copy(basecaps)
   113     if repo.ui.configbool('server', 'uncompressed', untrusted=True):
   114     if repo.ui.configbool('server', 'uncompressed', untrusted=True):
   114         caps.append('stream=%d' % repo.changelog.version)
   115         caps.append('stream=%d' % repo.changelog.version)
   115     if changegroupmod.bundlepriority:
   116     if changegroupmod.bundlepriority:
   116         caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
   117         caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
   117     rsp = ' '.join(caps)
   118     rsp = ' '.join(caps)