Fix chainability of $.fn.*_infobox

When I consolidated the code for the infoboxes, I broke jquery chaining. This
wasn't immediately obvious because it was only used for the user infobox
created from a draft reply comment (the "Add Comment" handler). This change
fixes it.

Testing done:
I could "Add comment" again.

Reviewed at https://reviews.reviewboard.org/r/6184/
Guess a file attachment's content type if application/octet-stream.

If a browser claims a file's content type is application/octet-stream,
get a second opinion by asking `file --mime-type`. This helps with some
browsers or server setups where that useless mimetype is being used,
preventing some files from being reviewable.

Fixes bug #2269
Reviewed at https://reviews.reviewboard.org/r/6016/
Don't trust the browser-provided mimetype if it looks bogus.

A user was reporting that their PDF file uploads were being assigned the
mimetype of "text/text/application/pdf", which is completely bogus. If
splitting on '/' produces anything other than a list of two strings, don't
allow it to proceed.

Testing done: Ran unit tests.

Fixes bug 3427.

Reviewed at https://reviews.reviewboard.org/r/6118/
Make SVN keyword handling case-insensitive.

Our existing handling for SVN keywords only works when the keywords had very
specific casing. This change fixes it to lower-case everything first, and does
a case-insensitive regex substitution.

Testing done:
Tested with several diffs that used svn:keywords with various casing.

Reviewed at https://reviews.reviewboard.org/r/6199/
Merge branch 'release-1.7.x' into release-2.0.x
Finish the merge.
Fix unicode problems when processing errors from SVN.

When processing any errors that come out of the pysvn client, we would cast the
exception to unicode without specifying an encoding. This resulted in any utf-8
filenames or other text triggering a UnicodeDecodeError. I've changed this to
first coerce the exception to bytes, and then decode. While I was in here, I
also fixed up a duplicate cast.

Testing done:
Ran unit tests (this error handler is exercised in the tests).

Fixes bug 3518.

Reviewed at https://reviews.reviewboard.org/r/6196/
Merge branch 'release-2.0.x'
Fix compatibility with Python < 2.7

My change for handling alternate casing in svn:keywords only worked with Python
2.7 (prior versions don't have a `flags` argument to `re.sub()`).

This change makes it so we compile the regex first using re.IGNORECASE, and
then call the substitution method on the regex object.

Testing done: Ran tests under python 2.6

Reviewed at https://reviews.reviewboard.org/r/6207/
Merge branch 'release-1.7.x' into release-2.0.x
Merge branch 'release-2.0.x'
Fix usage of _api_get in GitLab.

A change to the GitLab implementation to add support for more than 100 repos
ended up breaking things, because it changed the return signature of _api_get
without fixing up all the call sites. With the addition of the headers, we now
need to extract the first part of the tuple instead of just using the return
value directly.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6210/
Fix original-file and patched-file tests.

Some of the tests for the original-file and patched-file resources were failing
because it was trying to decode the responses as JSON. The problem was that one
of the GET test implementations was updated for the new
`basic_get_returns_json` field but not another. I've made an equivalent change
to handle it.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6211/
Fix account page tests.

The addition of the API tokens page for the user account preferences caused
some test breakages. I've fixed them, and also centralized the code a bit so
there are fewer changes to make when we change the structure of the pages.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6211/
Fix API token unit tests.

Several API tests were failing because the proposed token policies were missing
a "resources" field. I've added this to the tests, and refactored the common
data out so that if we want to make any changes to the policy string, it's only
in one place.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6213/
Change file attachment upload to use a backbone view.

This change adds a new backbone view for file uploads (the one that you see
when you click Update -> Add File). That popup was previously done via
$.formDlg and the old "datastore" code. Now it's a standalone view.
This will also be used for the future attachment updating feature.

Testing Done:
* Uploading new attachments.
* Error when no attachment is specified.
* Multiple errors returned from server side (see screenshots).

Reviewed at https://reviews.reviewboard.org/r/5911/
Clean up formDlg and gReviewRequest code.

Now that both the "Update Diff" and "Upload File" dialogs are handled via new
javascript code, we can get rid of a lot of legacy stuff. This change removes
review_request_dlgs.html, $.formDlg, and gReviewRequest.

Testing done: Ran javascript tests.
Don't cache commits as aggressively if 'branch' and 'start' aren't provided.

The code for getting the list of commits would cache for one day, but we only
want to do that if the branch and start commit are explicitly specified. If
not, we should still cache but for a much shorter period (to avoid the list
being up to one day out of date). This change fixes that.

Testing done:
- Tested svn post-commit list.
- Ran unit tests.

Fixes bug 3511.

Reviewed at https://reviews.reviewboard.org/r/6201/
Merge branch 'release-2.0.x'
Fixed subvertpy "Assertion `svn_uri_is_canonical(child_uri, ((void *)0))' failed"

There is an error in `list` function of subvertpy `Client` when `path`
parameter ends with trailing slash. This error also displays when running tests.

python: /build/buildd/subversion-1.8.8/subversion/libsvn_subr/dirent_uri.c:1499: uri_skip_ancestor: Assertion `svn_uri_is_canonical(child_uri, ((void *)0))' failed.

This change strips the trailing slash, fixing the error.

Testing Done: Ran unit tests.

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