tests/hgweberror.py
author Pulkit Goyal <7895pulkit@gmail.com>
Fri, 09 Feb 2018 15:49:46 +0530
changeset 37199 c5687ce3b411
parent 36887 4daa22071d5d
child 40155 0199fb5dde20
permissions -rw-r--r--
infinitepush: drop the `--to` flag to push and use `-B` instead The extension added a `--to` flag to specify the bookmark to which revs should be pushed. This patch deletes that flag and instead uses the `-B` flag. After this patch, bookmark passed as `-B` is parsed and if it matches the infinitepush bookmark pattern, we consider that push as infinitepush. This is still not the best of what we can do. Later patches in the series will drop the use of `-B` flag and will instead handle things at bookmark bundle2 part. Plugging these logic to bookmark bundle2 part will also get rid of the scratchbranchparttype bundle2 part. Differential Revision: https://phab.mercurial-scm.org/D2108

# A dummy extension that installs an hgweb command that throws an Exception.

from __future__ import absolute_import

from mercurial.hgweb import (
    webcommands,
)

def raiseerror(web):
    '''Dummy web command that raises an uncaught Exception.'''

    # Simulate an error after partial response.
    if 'partialresponse' in web.req.qsparams:
        web.res.status = b'200 Script output follows'
        web.res.headers[b'Content-Type'] = b'text/plain'
        web.res.setbodywillwrite()
        list(web.res.sendresponse())
        web.res.getbodyfile().write(b'partial content\n')

    raise AttributeError('I am an uncaught error!')

def extsetup(ui):
    setattr(webcommands, 'raiseerror', raiseerror)
    webcommands.__all__.append('raiseerror')