Switch to using ForwardingCacheBackend for all cache requests.

We now force ForwardingCacheBackend as the default cache backend, and
instead work with the 'forwarded_backend' cache name when looking up or
saving the real cache backend.

This covers the configuration forms, cache stats, and initial settings
population.

Reviewed at https://reviews.reviewboard.org/r/6482/
Fix "List index out of range" errors with interdiffing deleted files.

It's possible to hit an IndexError when processing an interdiff between two
changes that delete a file. The wrinkle here is that between the two revisions
of the diff, some additional changes to that file were made (and synced to the
local developer's tree).

The result of this is that we didn't filter out the file from the list of
things to show for the interdiff, and then things went wrong when we tried to
process the opcodes for diffing two empty strings.

While I was doing this, I saw some warnings about a unicode-unaware comparison
occurring, so I've slipped the fix for that in as well. This doesn't actually
have any correctness implications, it just speeds up things slightly when
dealing with empty files.

Testing done:
- Created a reproduction case for the bug and tested before and after the
  change. Before, I saw an entry for this file with the error inside. After,
  the deleted files don't show up at all in the interdiff.
- Ran unit tests.

Fixes bug 3481.

Reviewed at https://reviews.reviewboard.org/r/6473/
Merge branch 'release-2.0.x'
Fix some empty interdiffs resulting in a single equals chunk.

MyersDiffer had a bug where, if given an empty set of strings to
compare, it would yield an equal chunk. This could happen with
interdiffs when dealing with two deleted files, since both would end up
with empty strings.

The assumption was that if we reached the end of the processing and
haven't yielded anything, that it's an equal file. We'd then yield an
equal chunk with the ranges. In this case, the ranges would be 0,
causing index errors and bad assumptions later on. We now check for this
early and just bail.

Reviewed at https://reviews.reviewboard.org/r/6484/
Fix issues around the Whitespace Only logic and presentation.

If a file was processed that had no chunks, it would be listed as
whitespace-only. This was because the logic computing this would default
to whitespace-only, and then override that if it found any non-equal
chunks that contained real changes. For empty files, there were no
chunks to process, so this flag would be incorrectly set.

Even if the flag was correctly set, it still looked broken, as the
message describing that it's whitespace-only would be hidden by default.
The CSS rule for this has been removed.

While here, I also fixed up the labels for the toggles to not have such
varying mixed caps. That's been bugging me.

Reviewed at https://reviews.reviewboard.org/r/6485/
Compare file SHAs to determine if files can be skipped in interdiffs.

We attempt to keep unmodified changes out of the diff viewer when
viewing interdiffs. To do this, we compare the deleted flags and also
the diff contents. However, if the diff content simply has a small
change, like a difference in timestamps in the headers, this check will
fail and the otherwise unmodified file will be shown.

Now, when we generate diffs, we calculate SHAs and store them in the
file's extra_data. We can use these to compare the SHAs of patched files
to see if there will be any changes to show.

Reviewed at https://reviews.reviewboard.org/r/6486/
Add draft release notes for 2.0.9

This covers all of the changes that will ship in 2.0.9.

Testing done:
Built and reviewed HTML docs.

Reviewed at https://reviews.reviewboard.org/r/6472/
Merge branch 'release-2.0.x'
Harden repository passwords in the database.

Historically, passwords have been stored in plain text when directly
providing a repository not backed by a hosting service. Now, we store
this encrypted, like we do with any sensitive hosting service
information.

When upgrading the site, all passwords will be automatically migrated.

Reviewed at https://reviews.reviewboard.org/r/6400/
Release Review Board 2.0.9.
Merge branch 'release-2.0.x'
Dramatically improve dashboard query performance with relation columns.

The "Target People", "Target Groups", and "To Me" columns each added one query
per row. This change adds some smarts to the database accesses. The "To Me"
column now caches all of the directly-assigned review requests into a list
which is stored in the datagrid state. The target people and target groups
columns now do a prefetch_related() to have only one additional query for the
column, rather than one per row.

Testing done:
- Loaded the dashboard with all of these columns enabled. Before this change,
  for my particular set of review requests, it ran 29 queries in 25ms. After
  this change, the same dashboard ran with 11 queries in 12ms.
- Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6490/
Merge branch 'release-2.0.x'
Fix filename parsing when git filenames include spaces.

This is not perfect, but this should fix 99% of the cases. This will still show
incorrect filenames if path looks like /path/to b/your/file, but hopefully that
should be pretty rare..

Testing Done:
Tested with the dev server.

Fixes bug 3558.

Reviewed at https://reviews.reviewboard.org/r/6466/
Merge branch 'release-2.0.x'
Fix selecting text within a single line in the diff viewer.

The new text selection code only worked if the selected text had a <tr>
in it. If it didn't, we'd end up with an empty clipboard.

We now check for this condition, and just grab the text contents of the
selection.

Fixes bug #3631
Reviewed at https://reviews.reviewboard.org/r/6492/
Fix navigating to comment flags through key bindings in the diff viewer.

The support for navigating to comment flags using key bindings was
broken, due to looking up the wrong class. The class name has been
corrected, allowing navigation to work as expected.

Fixes bug #3626
Reviewed at https://reviews.reviewboard.org/r/6493/
Improve summary search speed on large installs.

Search for summaries in the quick search is very slow, for a couple of
reasons. We didn't have an index on the summary, but even if we did,
we were looking for text in the middle of the summary field, which
indexes can't help with.

This could cause real problems on large installs, slowing down the
database making it nearly impossible to find what you're looking for.
Continuing to type would trigger further expensive queries, eventually
resulting in other queries stalling on the server.

To fix this, we now have an index, and we now search only the beginnings
of summaries. We also only start searching if we have 4 or more
characters. It limitation on where we search sucks, but it's better than
nothing.

Theoretically, we could use the search index, but more work must be done
to make that happen.

We could also, theoretically, use the full-text search feature for
MySQL, but not all versions support that for InnoDB. Work would need to
be done to introspect whether we can use full-text search, and it would
require hand-applying some SQL to the database. It also wouldn't buy us
anything for other types of databases.

This may limit the usefulness of quick search for summaries until we
come up with something clever, but at least it won't break servers.

Fixes bug #3619
Reviewed at https://reviews.reviewboard.org/r/6494/
Fix problems in hardened password storage.

The password storage had a couple of bugs when saving empty passwords.

If a password was not set, but we tried to store it, we'd get '\tNone'.
This was due to always prefixing with the encrypted password marker, but
not actually encrypting the string. This would then break when we went
to load it, since 'None' wasn't an encrypted password.

We have to work around the loading, so we now check for '\tNone'. Sucks,
but now necessary. Down the road, perhaps we can convert any that are
busted during upgrade.

Storage has been fixed to serialize None values correctly.

Reviewed at https://reviews.reviewboard.org/r/6495/
Fix warnings about naive datetimes.

When we added timezone support, we updated almost everything to use it. The one
thing that was missed was the widgets in the admin dashboard, since we didn't
look at them too much. This meant that the log files were getting spewed with
warnings any time a user viewed the dashboard.

Testing done:
Viewed the dashboard and saw that there were no more naive datetime warnings.

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