Actually delete repositories through the webapi when they're empty.

If you delete a repository through the API, it doesn't actually delete it, it
just "archives" it (sets it to be invisible and changes the name). The reasoning
behind this is that we don't want to break any existing review requests.
Unfortunately, if you then try to create a new repository with the same path, it
will fail due to the unique_together constraints. This keeps hitting users of
RBCommons, where the API is the primary way that repositories are
managed--what's happening is that users create a repository and as they're
trying to get things working, they delete it. They then recreate it and hit a
constraint error.

Instead of blindly archiving, we now only archive if we actually have review
requests to preserve. This doesn't fix every possible case (maybe someone
created a test review request and then deleted the repository) but it should
handle most of the failures I've seen so far.

A better fix would be to do constraint checking by hand and only test for
uniqueness among visible repositories, but that involves schema changes.

Testing done: Ran unit tests. Verified that a DELETE call did what I expected.
Reviewed at http://reviews.reviewboard.org/r/3880/
Merge branch 'release-1.6.x' into release-1.7.x
Fix overzealous caching in admin dashboard widgets

The widgets in the admin dashboard cache their data in order to avoid doing
somewhat expensive computation every time the dashboard is loaded.
Unfortunately, this was a little too aggressive and didn't update correctly when
Repository or Group objects were created or deleted.

This change adds a "sync number" to the cache key, which is incremented whenever
one of the relevant models changes.

Testing done:
I check the Admin Dashboard after add a repository, then I can see correct data
on Repositories widget.

Fixes bug 2753.
Reviewed at http://reviews.reviewboard.org/r/3780/
Merge branch 'release-1.7.x'
Fixed error that failed to display user-not-found text in red error box.

When non-existant people or groups were entered into the review request target
reviewers fields, the error box didn't show the text correctly.

Testing done:
1. Incorrectly inputted into Group field - error appeared with text.
2. Incorrectly inputted into People field - error appeared with text.

Fixes bug 2869.
Reviewed at http://reviews.reviewboard.org/r/3756/
Merge branch 'release-1.7.x'
Try hard to get PYTHONPATH right for subprocesses.

This sets PYTHONPATH in two places, in an attempt to get it right for
all cases where we invoke subprocesses.

Newly generated reviewboard.wsgi files will have PYTHONPATH explicitly
set to include the conf directory.

We also set PYTHONPATH in initialize to that of sys.path, which should
ensure that, at least after the first URL access, we have all the
modules Review Board has access to available to the subprocess.

Fixes bug #2834
Update to Django 1.3.7.

This is the latest security release. Most of the issues shouldn't affect
us, but better safe than sorry.
Brand new user sees "None" for all dashboard counts in a local site.

Fix the Starred Public Review Count for new user

The CounterField initializer for starred_public_request_count was calculating
the count as 0 if the pk of that table was not null. The parantheses for this
calculation was not setup properly , which caused the value to be setup as None
for the first time user.

Also fixed a test which was assuming that the first time user will see None for
the counts. With this and the associated djblets fix, this isnt true anymore.
This fixes the reviewboard side of things and is associated to the review
request 3841 (which is a djblets fix).

Testing done: Manual testing with localsites and regular ones. Ran all
reviewboard tests.

Fixes bug 2873.
Reviewed at http://reviews.reviewboard.org/r/3842/
Fix a crash when the right-side diff doesn't have a header.

There was an error when parsing a diff where there were headers on the
left-hand side but not the right-hand side. The solution was found by
Ze Lin Xiao at NetApp.

Fixes bug #2876
Strip whitespace from STMP server names.

The STMP server configuration would fail if there was trailing whitespace on the
server name. This was a problem when copy/pasting text into the form.

Testing done:
Produced the bug with an smtp server "smtp.gmail.com     " and triggered an
email event (registration for new user). Log produced an error: "Unknown host".
Added the changes on the diff and tried again, the email is sent and the value
that is saved is stripped of the redudant spaces.

Reviewed at http://reviews.reviewboard.org/r/3759/
Fixes bug 2620.
Fix a regression with displaying diff viewer file entries.

The "Files Changed" list in the diff viewer broke with Windows-style
paths. A previous change was made to fix a JavaScript injection issue,
but that caused some escaping issues when using backslashes. We now
escape both HTML and JavaScript.
Undo the ALLOWED_HOSTS change.

This slipped in when I was testing, and just breaks things. Get rid of it.
Release Review Board 1.6.16.
Merge branch 'release-1.6.x'