Add type safety for post-commit SCM objects and fix some type issues.

Review Request #10497 — Created April 2, 2019 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

This adds type safety to important attributes on Branch, ChangeSet,
Commit, and Revision, forcing hosting services and SCMTools to
encode or decode data properly and pass the right types during
construction. This allows consumers of these objects to be certain about
what type they're working with, and just keeps everything nice and
consistent across implementations and Python versions.

The new type safety caught some issues in a few of our backends, where
we were passing Unicode diffs or byte string metadata. These haven't
been a problem before (and we had some backwards-compatibility support
in Commit that dealt with Unicode diffs, which are now gone). These
cases have all been updated to pass the correct types.

Unit tests pass on Python 2.7 and 3.7 (with other in-progress changes).

Tested browsing for commits and posting commits for review using GitHub,
Subversion, and Perforce (the three most heavily changed), complete with
diffs using Emoji characters.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

orig
1
2
3

Commits

First Last Summary ID Author
Add type safety for post-commit SCM objects and fix some type issues.
This adds type safety to important attributes on `Branch`, `ChangeSet`, `Commit`, and `Revision`, forcing hosting services and SCMTools to encode or decode data properly and pass the right types during construction. This allows consumers of these objects to be certain about what type they're working with, and just keeps everything nice and consistent across implementations and Python versions. The new type safety caught some issues in a few of our backends, where we were passing Unicode diffs or byte string metadata. These haven't been a problem before (and we had some backwards-compatibility support in `Commit` that dealt with Unicode diffs, which are now gone). These cases have all been updated to pass the correct types.
e94bd31d4ac6243f9f2c08fe2abbb1286cb6c898 Christian Hammond
reviewboard/diffviewer/commit_utils.py
reviewboard/hostingsvcs/github.py
reviewboard/hostingsvcs/rbgateway.py
reviewboard/scmtools/core.py
reviewboard/scmtools/hg.py
reviewboard/scmtools/perforce.py
reviewboard/scmtools/svn/__init__.py
reviewboard/scmtools/tests/test_core.py
Loading...