Backport change: Some cleanups in the 'api' branch.

Many of these cleanups apply nicely to master, and will make merging
easier later on.

Original description:

Some cleanups in the 'api' branch.

This cleans up some of the code on the 'api' branch. It removes trailing
whitespace, aligns parameters, fixes some PEP-8 problems, gets rid of
some old files, fixes references to new ones, and more.

Reviewed at http://reviews.reviewboard.org/r/2400/
Add tests and a test base class for rbtools.utils.

This introduces some unit tests for the rbtools.utils module. As part
of this, in order to ease testing, a RBTestBase class was added, which
contains several utility functions that will help in testing the
client and API support.

Reviewed at http://reviews.reviewboard.org/r/2518/
Move config loading into rbtools.utils and add tests.

The code for handling config files has been moved out of post-review
and into rbtools.utils.filesystem where it can be used by other
utilities.

Reviewed at http://reviews.reviewboard.org/r/2519/
Fix setting the configs variable in post-review.

The config loading wasn't setting the global 'configs' variable. Now it's
explicitly setting the global variable.
Fix Mercurial test failure related to missing config loading.

A Mercurial test wasn't calling load_config_files, causing a test failure.

Reviewed at http://reviews.reviewboard.org/r/2547/
Fix an error when posting a review inside a mercurial branch.

The _get_top_and_bottom_outgoing_revs method for the MercurialClient
was assuming all revision numbers were consecutive which is not necessarily
true at all times, especially when branches exists. This change tries to
fetch the "parent" revision instead of just subtracting one to the bottom_rev
to be reviewed, if this revision is not found it falls back to the old
behavior.

Reviewed at http://reviews.reviewboard.org/r/2487/
Fix an error when posting a review inside a mercurial branch.

The _get_top_and_bottom_outgoing_revs method for the MercurialClient
was assuming all revision numbers were consecutive which is not necessarily
true at all times, especially when branches exists. This change tries to
fetch the "parent" revision instead of just subtracting one to the bottom_rev
to be reviewed, if this revision is not found it falls back to the old
behavior.

Reviewed at http://reviews.reviewboard.org/r/2487/
Accept a single revision ID for --revision-range for Mercurial.

Mercurial now supports --revision-range with a single revision ID now. If
given a single revision, it will find the first parent of that revision and
use that as the first revision of the diff.

Reviewed at http://reviews.reviewboard.org/r/2546/
Merge branch 'release-0.3.x'
Modernize the release script.

The release script is now on par with Review Board's. It generates sha1s of
the released files and uploads them, and it knows how to update reviewboard.org
with the new release information.
Release RBTools 0.3.3.
Bump to RBTools 0.3.4 dev.
Merge branch 'release-0.3.x'
Bump to RBTools 0.4.0 dev.
Move SCMClient unit tests into clients/tests.py, and improve the test utils.

All SCMClient unit tests have been moved out of rbtools/tests.py and into
rbtools/clients/tests.py. Some of the utility functions have been moved out
into testbase.py.

Reviewed at http://reviews.reviewboard.org/r/2452/
Add the missing tests from Alexander's change.
Strip newlines out of concatenated summaries.

When posting a review using --guess-summary, we would concatenate all of the
summary lines, including newline characters. If one then tried to publish the
review as such, the email layer would freak out because there were newlines in
the subject header.

Fixes bug 1689
Handle authentication failures when accessing /api/info/.

When accessing a password-protected /api/info/ path, we wouldn't gracefully
handle an invalid login. Instead, we would fall back on the old, deprecated
API. This would always fail on RB 1.6, making things very confusing. Now we
handle this better and just simply bail if we can't log in the first time.
Merge branch 'release-0.3.x'
Fix uploading diffs with non-ascii characters on Python 2.7.

Python 2.7's urllib2 has some brokenness when uploading content with
non-ascii characters. This is due to encoding differences between the
content and the URL, and how it ends up involving both. Specifically
passing str(url) seems to fix this.

Reviewed at http://reviews.reviewboard.org/r/2568/
Fixes bug #2155