This is largely a rewrite of the Bitbucket hosting service backend that
aims to throw out old Bitbucket API 1.0 conventions (such as error
introspection and pagination workarounds) in favor of API 2.0, and to
leverage the modern hosting service support in Review Board 4.0.
Much like the recent RB Gateway rewrite, the new BitbucketClient
class
takes care of all communication, standardizing all error handling, URL
building, and authentication. It implements API accessors for everything
that the service backend needs, and it all goes through the modern HTTP
request code.
API accessors that deal with paginated payloads now wrap the results
using the new BitbucketAPIPaginator
class, which gives us a single
standard way to handle pagination.
The service backend no longer directly performs any HTTP requests,
instead calling into the API accessors on the client, providing
arguments based on the account or repository information and turning the
results into the proper objects (or returning them directly).
The truncated commits handling for the WebHook push event also leverages
the new paginator class, using it to limit the number of pages of
results and to simplify the logic, making it less error-prone.
The authentication form now rejects Bitbucket usernames comprised of
e-mail addresses, which has been a common source of confusion ever since
Atlassian changed to having users log in via their e-mail accounts but
kept usernames for the Bitbucket API.
Documentation has been added all throughout, and unit tests have been
updated for the new requirements.