Update Bitbucket to use the 2.0 API.

Review Request #8816 - Created March 15, 2017 and submitted

Christian Hammond
Review Board

This moves us entirely (almost) onto the Bitbucket 2.0 API. The old 1.0
API has a number of bugs, which have bit some users, and 2.0 has
recently been expanded to include most of what we need (without the
bugs and with improved error reporting).

We now use the 2.0 API for retrieving branches, commits, checking the
repository, and validating the user. We can't use it yet for fetching
the contents of files, though, as that's still a 1.0-only feature
(though is being tracked upstream by Bitbucket -- see

One of the advantages of the new API is that payloads can be limited to
the specific fields needed in a client. We now use this to slim down
communication with Bitbucket.

There's also additional bullet-proofing in here for validating that the
repository is of the correct type, based on the choices selected in the
repository form.

Unit tests passed.

Tested with a handful of repositories (Git and Mercurial, and including
one that triggered crashes in the Bitbucket API). I tested that
repository validation, account linking, branch/commit listing, and
file fetching all work.

Review Bot
Barret Rennie
David Trowbridge
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (3b9c6c5)