Don't use six on release-1.7.x.

A change I crossported used six.text_type. Since this doesn't exist here, don't
use it.
Merge branch 'release-1.7.x' into release-2.0.x
Allow auth backends to act on a user-list query before it's executed.

Added an overrideable function to AuthBackend which is called at the beginning
of UserResource.get_query_set(), which in turn is called by the GET /users/
WebAPI call.  The default function does nothing.  This allows backends to add
their own logic to fetch users from an external source and add them to the
local user database (or update existing users) before the db query is executed.

I added docs and fixed the doc for another AuthBackend overrideable function
while I was there.

Testing Done:
All tests pass aside from a few VCS-dependent ones, which are skipped.

Reviewed at https://reviews.reviewboard.org/r/5521/
Fix get_auth_backends usage.

The patch I just pushed was based on an older revision, and used
get_auth_backends, which Christian recently renamed. This changes it to use
get_enabled_auth_backends instead.
Fix move ranges spanning different remove groups.

When a move range for inserts spanned remove groups on the left-hand
side, the resulting move ranges would appear to be offset in weird ways.

What was happening was that, while determining the range, we'd keep
seeing new remove groups on the left-hand side, which would cause us to
reset our ranges. The final remove group on the left-hand side would
account for the range length, and the range would appear to start on
that side at the top of that group. However, on the right-hand side,
it'd start at the correct place, but have the truncated range.

To fix this, we need to do a few things:

1. We need to glue the remove groups together better. When we see a
   new group (such as when going from a delete to a replace), we now
   check if it immediately follows the last move range we were working
   with. If so, we use that instead.

2. We then needed to terminate those ranges by resetting prev_key when
   we know we're not going to be continuing a range.

3. We need to store all groups within the range, and set the move
   opcodes on all of them. We were previously only dealing with the
   first (or sometimes last -- depending on the code path) group,
   which would prevent us from being able to show the range in the
   diff viewer.

4. Upon encountering a blank line, we need to be sure to add that
   line's opcode group to the list of groups. Even if it's an "equal"
   (which will now show up in a move range, but only where it's
   appropriately bridging two consecutive ranges).

5. When drawing the move ranges, we can't rely on computations from
   the previous line, because we only have the previous line within
   that chunk. So now we store info on the start of a range along
   with the to/from line number. That lets us simplify the move
   range drawing quite nicely, and guarantees it reflects what's
   computed.

To make all this a lot nicer, I've added a container for move ranges,
called MoveRange. This keeps track of the start and end, and the
affected groups. It's cleaner than rebuilding and indexing tuples
everywhere.
Fix a ton of PEP-8 issues.

Since ReviewBot has been slacking off, a bunch of issues have slipped in (plus
there are a lot that we just never fixed up). This change fixes almost
everything, with the exception that a few things PEP-8 thinks are problems are
actually preferred.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/5509/
Fix usage of 'apache_auth' field for templates.

If deploying with lighttpd, there won't be any definition for 'apache_auth'. We
should therefore avoid trying to use it. Trivial change.

Fixes bug 3263.

Reviewed at https://reviews.reviewboard.org/r/5561/
Fix user profile form saving.

The profile form only saved values if the backend *didn't* support changing
them. This looks like a copy/paste-o.

Testing done: Changed my real name and email address successfully.

Fixes bug 3268.

Reviewed at https://reviews.reviewboard.org/r/5559/
Fixed the alignment of line numbers on moved rows in diffs.

A couple fixes were attempted in the past to fix alignment of line
numbers whne moved rows came into play. The reason they didn't work was
the (fairly reasonable) assumption that every moved row had the
'.moved-row' CSS class. This was only set for the rows with move flags,
though.

Since that's a pretty decent assumption to make, let's make it true.
Every moved row now has the '.moved-row' class applied.
Fix the style for moved replace lines.

An older style from my initial move enhancement change earlier in 2.0
caused lines to have excess padding where they shouldn't.

The intent, I believe, was to add some padding between the move flag and
the text, but why this was only on replace lines, I'm not sure. This
change fixes the style by marking lines where a move flag is shown, and
adding 4x of padding between it and the text on both columns.
Show and hide the "Download Diff" link depending on the interdiff state.

When I made the diff revision selector operate without reloading the page, I
neglected the "Download Diff" link at the top of the page. This link should
only be shown when the page is displaying a full revision, and not when there's
an interdiff.

I've changed it to use an inline style to hide the link on the first page load
if appropriate, and JS to show/hide it when the displayed revision changes.

Testing done:
Played around with the revision selector and watched the link show and hide
itself. Verified that if I initially loaded an interdiff, that the link was
present in the DOM to show later.

Fixes bug 3269.

Reviewed at https://reviews.reviewboard.org/r/5560/
Increase the size of the comment dialog.

The comment dialog's a bit small, and that makes it harder to show code
samples or construct more detailed comments.

This change increases it by 50px in both directions. While not a major
increase, it feels like it.
Improve performance when rendering diff lines.

This makes a number of optimizations to our diff rendering process:

1. Some unnecessary string comparisons from the diff_lines template tag
   have been simplified, so that we're only ever comparing one string.
   Small change, but one that should add up over the course of diffs.
   From performance testing, this appears to be roughly 30% faster
   overall.

2. We were checking if we needed to highlight regions for every
   single line, not just replace lines. This meant we did empty string
   checks, length checks, and string comparisons for every single line.
   These also added up, even though it only ever triggered the
   highlight region code for replace lines.

   Instead of all this work, we now check if it's a replace line
   up-front, preventing all the other checks.

3. Highlighting regions for a replace line is now twice as fast.
   Instead of parsing every character and keeping track of state,
   we're making use of `str.find`, which is much faster. We're also
   grabbing ranges of a string at a time, and reducing accesses to
   indexes of regions.
Fix incorrect labelling on review request status graph in admin.

The admin site has a widget that shows the percentage of all review requests in
various states. Unfortunately, this graph shows requests with a status of "D"
as drafts instead of as discarded.

I've fixed this graph to split things based on public or non-public, which
actually shows the draft state. I've then renamed the "D" state to be correct.

Testing done: Looked at the graph in the admin site using data from r.rb.o.

Fixes bug 3270.
Merge branch 'release-1.7.x' into release-2.0.x
Merge branch 'release-2.0.x'