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/
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.