view tests/hgweberror.py @ 24812:e4e69cebeedd stable

largefiles: don't crash when cloning to a remote repo The immediate crash was when checking for requirements immediately after this, but lfcommands.downloadlfiles() will also crash if --all-largefiles is specified. That has been in place since atleast 5884812686f7 (2.3-rc) without anyone noticing. I can't tell from the peer classes if there's a way to make the custom largefile functionality work in this case, but atleast it doesn't crash.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 18 Apr 2015 00:34:38 -0400
parents dc4d2cd3aa3e
children 74e6de99ce7f
line wrap: on
line source

# 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')