Update the Mercurial hgweb support for Python 3.x and Review Board 4.0.

Review Request #10931 — Created March 2, 2020 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

The Mercurial hgweb backend had a couple of compatibility problems that
prevented it from working on Python 3 and Review Board 4.0. It was
trying to parse JSON payloads in the form of byte strings, which is not
supported on Python 3. Instead, we needed to ensure we were providing
Unicode strings. A handy new _get_http_json() method now does the work
of ensuring we're using the correct types.

When building commits, it was still passing a base_commit_id=
parameter to the Commit constructor, which has been removed in
Review Board 4.0. This was missed before due to the lack of unit tests
for the hgweb support.

Since we now have a _get_http_json() method that handles JSON API
requests in a more standardized way, we're also in a better position to
future-proof by checking if endpoints are implemented (comparing a payload
to b'not yet implemented') and then returning None. This ensures
we don't break with older versions of Mercurial now, and that going
forward we can introduce support for newer APIs without outright breaking
on version that lack them.

To ensure we have working compatibility now and in the future, this
change also adds unit tests that cover the hgweb communication.

Manually tested loading branches and commits, posting a change for
review, and viewing a diff.

Unit tests pass on all supported versions of Python.

Commits

Files