Fix some validation issues and error display on Bitbucket.

It was common for people to put invalid repository names or usernames
into the Bitbucket repository config form. When this happened, we'd
either end up storing bad account information, fail with a cryptic
error, or crash.

Some of the most common problems here have been fixed.

We now check the the validity of the username and password prior to
storage. We fetch the user session API, using the credentials provided
by the user. The credential data is only stored if this succeeds.

If any API request results in an HTTP 401, we raise an
AuthorizationError. All other errors result in a HostingServiceError
(previously, we'd raise an Exception, which wouldn't always be caught
correctly). If the data from the server was a valid error payload, we
now parse that and display the error message.

Repositories are now validated properly as well. A repository name that
looks like a path (has a '/') or contains '.git' will immediately result
in an error instructing the user to provide just the name. If a name
meets the criteria, but is not found, a suitable error will also be
shown instead of a JSON payload.

Reviewed at https://reviews.reviewboard.org/r/6359/