tests/hgweberror.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 23 Jan 2015 14:09:49 -0800
changeset 24004 8a5267cd5286
parent 23409 dc4d2cd3aa3e
child 27299 74e6de99ce7f
permissions -rw-r--r--
parsers: rewrite index_ancestors() in terms of index_commonancestorsheads() The first 80% of index_ancestors() is identical to index_commonancestorsheads(), so just call that function instead.

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

from mercurial.hgweb import webcommands

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

    # Simulate an error after partial response.
    if 'partialresponse' in req.form:
        req.respond(200, 'text/plain')
        req.write('partial content\n')

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

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