mercurial/hgweb/protocol.py
author Matt Mackall <mpm@selenic.com>
Thu, 15 Jul 2010 11:24:42 -0500
changeset 11593 d054cc5c7737
parent 11585 5d907fbb9703
child 11594 67863f9d805f
permissions -rw-r--r--
protocol: unify unbundle on the server side

#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import cStringIO, zlib, tempfile, errno, os, sys, urllib, copy
from mercurial import util, streamclone, pushkey
from mercurial.node import bin, hex
from mercurial import changegroup as changegroupmod
from common import ErrorResponse, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR

# __all__ is populated with the allowed commands. Be sure to add to it if
# you're adding a new command, or the new command won't work.

__all__ = [
   'lookup', 'heads', 'branches', 'between', 'changegroup',
   'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
   'branchmap', 'pushkey', 'listkeys'
]

HGTYPE = 'application/mercurial-0.1'
basecaps = 'lookup changegroupsubset branchmap pushkey'.split()

def capabilities(repo, req):
    caps = copy.copy(basecaps)
    if streamclone.allowed(repo.ui):
        caps.append('stream=%d' % repo.changelog.version)
    if changegroupmod.bundlepriority:
        caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
    rsp = ' '.join(caps)
    req.respond(HTTP_OK, HGTYPE, length=len(rsp))
    yield rsp