( )⚙ D2786 hgweb: support using new response object for web commands

This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: support using new response object for web commands
ClosedPublic

Authored by indygreg on Mar 11 2018, 12:23 AM.

Details

Summary

We have a "requestcontext" type for holding state for the current
request. Why we pass in the wsgirequest and templater instance
to @webcommand functions, I don't know.

I like the idea of standardizing on using "requestcontext" for passing
all state to @webcommand functions because that scales well without
API changes every time you want to pass a new piece of data. So,
we add our new request and response instances to "requestcontext" so
@webcommand functions can access them.

We also teach our command dispatcher to recognize a new calling
convention. Instead of returning content from the @webcommand
function, we return our response object. This signals that this
response object is to be used for sending output. The keyword
extension was wrapping various @webcommand and assuming the output
was iterable, so we had to teach it about the new calling convention.

To prove everything works, we convert the "filelog" @webcommand
to use the new convention.

The new calling convention is a bit wonky. I intend to improve this
once all commands are ported to use the new response object.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Mar 11 2018, 12:23 AM
durin42 accepted this revision.Mar 12 2018, 5:08 PM
This revision is now accepted and ready to land.Mar 12 2018, 5:08 PM
This revision was automatically updated to reflect the committed changes.