This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: always return iterable from @webcommand functions (API)
ClosedPublic

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

Details

Summary

We had to hack up this function to support our transition to the
new response API. Now that we're done with the transition (!!),
we can return to returning an iterator of content chunks from
these functions.

It is tempting to return a normal object and not a generator.
However, as the keyword extension demonstrates, extensions may
wish to wrap commands and have a try..finally block around
execution. Since there is a generator producing content and
that generator could be executing code, the try..finally needs
to live for as long as the generator is running. That means we
have to return a generator so wrappers can consume the generator
inside a try..finally.

.. api::

hgweb @webcommand functions must use the new response object
passed in via ``web.res`` to initiate sending of a response.
The hgweb WSGI application will no longer start sending the
response automatically.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

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