Correctly store base revision for Mercurial diffs with parent diffs.

Mercurial diffs with parent diffs do not work at all in RB 1.7.7.1 if there is
no overlap between the files in the diff and those in the parent diff.

This change fixes the issue and improves the method of dealing with Mercurial
diffs that was introduced changeset 6b1f537b4cf9. The old method was somewhat
fragile and was broken by changeset 562a8b4a21a9.

Testing done:
Tested using a local repo on which the problem was originally seen.
Added a unit test that tests this scenario.

Fixes bug 2971.
Reviewed at https://reviews.reviewboard.org/r/4121/
Fix the gitweb URL format in the docs.

The example for a raw file URL using gitweb said to use hb=<revision>, but the
correct format is h=<revision>

Fixes bug 3027.
Tell users to back up their database before upgrading their sites.

We do this when we're answering people's questions on the mailing list, so we
should probably do so in the docs as well.
Remove executable bit from static and templates files.

Some files (mostly ones which were extracted from a third-party archive) had
the executable bit set. Remove it.

Fixes bug 3038.
Fix ValueError when the user enters a bad cache host.

If the user enters a cache hostname which doesn't split properly, it makes the
admin site unavailable. This is because the cache stats code was just blindly
trying to unpack the values without any error handling. I've updated it to
cache this case, log, and continue.

Fixes bug 3049.
Reviewed at https://reviews.reviewboard.org/r/4402/
Make issue_opened and issue_status more consistent.

If a user creates a comment with an issue, and later removes that issue before
publishing, we end up in a weird state where the issue_status is still 'O' but
issue_opened is false. This change fixes it to clear out issue_status when
removing the issue_opened bit.

Testing done: Ran unit tests.
Fixes bug 2984.
Reviewed at https://reviews.reviewboard.org/r/4404/
Set the cwd of 'patch' to be the tempdir.

This isn't usually necessary, but at least one person reported an instance
where it was (probably depending on their version of the `patch` command), and
it doesn't hurt anything.

Fixes bug 2065.
Merge branch 'release-1.7.x'
Merge branch 'release-1.7.x'
Add a UserPageSidebarHook for adding links to user pages

This patch adds support for adding extensions in UserPage and works very
similar to the DashboardHook. It takes a dictionary of label, url and an
optional subitems -- which itself can be an array of (label,url) -- to add
custom links in the /users/<username> page.

Also updated the documentation page to indicate the usage of this. Im not sure
how to build the doc page into html, so the formatting hasnt been checked for
the new documentation.

I added support for this hook so that people wanting to build user-specific
reports can use this. For e.g. reports like review-requests assigned to me, or
a users' RSS feed can all be linked directly from a user page.

Testing done:
- Ran all existing tests.
- Added a new test for the UserPageHook.
- Added a new test extension that demonstrates the use of this (Screenshot
  attached).
- Tested without extension to ensure no other breakage.

Reviewed at https://reviews.reviewboard.org/r/3875/
Refactor logic out of UploadDiffForm

All of the logic for taking a diff file and creating a DiffSet was in
UploadDiffForm. This change moves it out into a manager, so that I'll be able to
use the same code for creating DiffSets from diff data fetched from an upstream
repository.

Testing done: ran unit tests.
Reviewed at http://reviews.reviewboard.org/r/4231/
Merge branch 'release-1.7.x'
Fix positionNotifyBubble.

At some point, the argument to this method got changed from bubble to $bubble,
but not all references were updated.
Commenting functionality for text-based review UIs

Implement functionality to allow text-based rendered review UIs to be commented
on. This would allow users to comment on Markdown, XML, and RST rendered UIs
(to name a few).

The functionality is done by:
- Creating a TextBasedReviewable. This inherits from FileAttachmentReviewable.
  All text-based UIs must now inherit from TextBasedReviewable for commenting
  functionality.
- Creating a TextBasedCommentBlock view and model. These comment block view
  is used in TextBasedReviewable as the comment block view.

In TextBasedReviewable, each rendered element is wrapped with
  <div class="text-review-ui-container" data-child-id="{id of child}"></div>

  (Note: this is not done recursively. If there is a paragraph with multiple
  nested hyperlinks, only the paragraph will be wrapped -- not the nested
  hyperlinks).

  The id that is assigned is unique auto-incremented ID. If there are n
  elements that will be wrapped, the IDs will range from [0..n-1].

A ghost comment icon is also displayed for the comments. This styling for this
has been borrowed from diffviewer.

Testing done:
This patch was applied on r/3434 (Markdown Review UI) and all testing was done
on that review UI.

- Created single comment
- Created multiple comments on the same element
- Created multiple comments on different elements

(Did the above 3 with issues as well)

In all tests, everything saved and published successfully. Upon refreshing the
rendered UI, the comments were displayed in the ghost comment icon and
mouseover/click worked.

Additionally, I made sure that nothing was broken in side-by-side diff after I
made changes to diffviewer.less.

This was tested on Chrome on Mac.

Reviewed at https://reviews.reviewboard.org/r/3613/
Add a field to DiffSet for storing the commit ID a change is based on.

This field can be set when uploading a diff via the API. We can make use
of it for certain hosting services that only provide file fetching APIs
that take Git commit SHA1s instead of blob SHA1s.

The field is optional. RBTools will be updated to set it for Git, but it
will otherwise be used only as needed.
Add a stronger warning about fastcgi.

Apparently fastcgi is also responsible for the API issues with LDAP auth. Since
there's not much we can do about this from our side, I've changed the docs to
just more heavily recommind mod_wsgi.

See issue 2322 for more details.
Handle "(revision )" for source files.

Our svn revision parsing code already had a special case for the pretty wacky
"(revision )", but it only worked when this was seen for the new revision. If
we got this for the source revision, we'd hit various errors. I've changed the
logic to report this as PRE_CREATION, which shouldn't break the old IntelliJ
diffs but should work for whatever wonky tool was used for bug 2632.

Testing done: Ran unit tests.
Fix PEP-8 issues in accounts/ and admin/

This change fixes up most of the issues found by the pep8 tool. The ones that I
left where where we had mapping tables that were formatted for readability.

Reviewed at https://reviews.reviewboard.org/r/4412/
Add infinite scroll for commits in the new review request UI.

This change makes it so scrolling to within 50px of the bottom of the list of
commits in the New Review Request page will automatically load another page.
This shows the little "Loading..." spinner at the top, but is otherwise pretty
seamless.

Testing done:
- Loaded many pages of commits.
- Connected a repo with only a small number of commits, and saw that it stopped
  loading once I hit the bottom.

Reviewed at https://reviews.reviewboard.org/r/4411/
Fix default value for HostingService._http_request headers parameter

The default value for the 'headers' parameter to the _http_request was None,
which meant that if something called it without passing in headers,
urllib2.Request()'s constructor would throw an exception. Other similar code
uses a default value of an empty dictionary, which is more appropriate.

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