Switch to ldap.initialize() for AD backend.

The AD backend was still using the deprecated ldap.open() call. This is a
trivial change which switches it over to using ldap.initialize(), which just
takes a URI instead of host/port parameters.
Fix SSL regressions with Subversion.

Subversion's SSL support badly broke with the subvertpy work done in
2.0. The new code flat-out didn't work with self-signed certificates,
and seemed to have trouble with verification all-together. This was true
of both PySVN and Subvertpy.

In PySVN's case, the SSL trust callback was never set. The base SVNTool
tried to set it on our Client class for PySVN, but it never got set on
the real Client class provided by PySVN.

Subvertpy was missing a bunch of provider classes that were necessary
for reading and writing the certificate verification files in the
.subversion directory.

In both cases, the new accept_certificate() functions were failing to
actually return the generated certificate. They were also not being
careful with the 'failures' key in the resulting certificate. PySVN
prematurely deleted it (causing us to fail when looking up the failures,
if needed), and Subvertpy was leaving it in.

This brings our support for SSL certificates back to a working state.

Fixes bug #3317
Reviewed at https://reviews.reviewboard.org/r/5936/
Speed up search indexing.

Search indexing was painfully slow, since every single ReviewRequest
being indexed ended up adding one query for the submitter and one to get
a list of all FileDiffs.

The FileDiffs query in particular resulted in quite a lot of unnecessary
time spent.

By taking advantage of select_related(), prefetch_related(), and a
prepare_file() statement, we can reduce this down to only 2 additional
queries per batch of review requests (as defined by Haystack, defaulting
to 1 large batch).

Reviewed at https://reviews.reviewboard.org/r/5935/
Add web API support for querying remote repositories.

This adds a new child resource off the HostingServiceAccount resource
for querying remote repositories.

Since every hosting service works differently, this resource needs to
take different query parameters depending on the hosting service it's
querying. Specifically, the 'owner-type' and 'filter-type' values.

Reviewed at https://reviews.reviewboard.org/r/5917/
Add a capability for whether a HostingServie can list remote repos.

This adds HostingService.supports_list_remote_repositories, which is
used for determining if get_remote_repositories() and
get_remote_repository() can be called. This defaults to false, but
GitHub enables it.

The API exposes this on HostingServiceResource, and
HostingServiceAccountResource uses it to determine whether to show a
'remote_repositories' link.

Reviewed at https://reviews.reviewboard.org/r/5923/
Stop reloading siteconfigs on every request, and fix log reloads.

We were reloading siteconfigs on every single request, which was
unnecessary. It was only necessary to reload if the siteconfig had
changed since it was last used. This wasn't particularly time-consuming,
but it was extra work that shouldn't be needed, and it made it hard to
handle reloads of logging.

To track whether a siteconfig should be reloaded, we now check a private
flag on the SiteConfiguration. If it's not set, we perform a full reload
(which now restarts logging as well, something that was missing and hard
to do correctly before). If it is set, we do nothing.

Reviewed at https://reviews.reviewboard.org/r/5931/
Merge branch 'release-2.0.x'
Update a legacy import for djblets.webapi.core.

The new RemoteRepositoryResource was importing from the old
djblets.webapi.core, causing a DeprecationWarning. This fixes the import
to use the new location.
Handle LookupErrors in repository encoding along with UnicodeError.

If the encoding field for a repository has garbage entries, or a system is
missing the locale information, trying to decode given a specific encoding
might fail with LookupError. In this case, we want to just continue through
with the rest of the logic.

Testing done: Ran unit tests.

Fixes bug 3399.
Merge branch 'release-2.0.x'