Mercurial > hg
annotate tests/hgweberror.py @ 32252:d67991c4fefe
treemanifest: allow manifestrevlog to take an explicit treemanifest arg
Previously we relied on the opener options to tell the revlog to be a tree
manifest. This makes it complicated for extensions to create treemanifests and
normal manifests at the same time. Let's add a construtor argument to create a
treemanifest revlog as well.
I considered removing the options['treemanifest'] logic from manifestrevlog
entirely, but doing so shifts the responsibility to the caller which ends up
requiring changes in localrepo, bundlerepo, and unionrepo. I figured having the
dual mechanism was better than polluting other parts of the code base with
treemanifest knowledge.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 09 May 2017 13:56:46 -0700 |
parents | 74e6de99ce7f |
children | 3d60a22e27f5 |
rev | line source |
---|---|
23409
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # A dummy extension that installs an hgweb command that throws an Exception. |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
27299
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
3 from __future__ import absolute_import |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
4 |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
5 from mercurial.hgweb import ( |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
6 webcommands, |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
7 ) |
23409
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 def raiseerror(web, req, tmpl): |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 '''Dummy web command that raises an uncaught Exception.''' |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 # Simulate an error after partial response. |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 if 'partialresponse' in req.form: |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 req.respond(200, 'text/plain') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 req.write('partial content\n') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 raise AttributeError('I am an uncaught error!') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 def extsetup(ui): |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 setattr(webcommands, 'raiseerror', raiseerror) |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 webcommands.__all__.append('raiseerror') |