Fix some further Python 2.4 issues.

There were a few new-style exception catches (except Foo as e) and some
"a = b if c else d" logic which was breaking Python 2.4. Switch to the
old-style ways of doing these.
Release RBTools 0.4.1.
Fix handling of revisions with deleted files for SVN.

The implementation of post-review did the wrong thing when the SVN revision had
a deleted file. Posting the diff manually worked fine, so the bug was entirely
in the post-review side.

This patch has been kicking around in our bug tracker for more than a year, in
formats which made it very hard to review. Multiple posters there vouched that
it worked.

Fixes bug 1113.
Fix issues running post-review within a git-submodule with recent git versions.

On recent versions of Git, the .git directory for a submodule was
relocated to being in the top-level project instead of in the worktree
of the submodule.

This change attempts to get the top-level directory, if we can get it,
falling back on the old behavior for older versions of Git.

Fixes bug #2526
Reviewed at http://reviews.reviewboard.org/r/2960/
Protect the cookies file with a restrictive umask

Currently the .post-review-cookies file is created using the default
system umask. On many UNIX systems this will create a file which is
world-readable, thus potentially exposing the user's reviewboard
credentials to any other user on that system.

Setting the umask to 0077 should cause the file to be created with
permissions 0600, i.e. readable only by the current user. This will
only apply to new files and not existing ones.

Ran unit tests.

Fixes bug 2231.
Reviewed at http://reviews.reviewboard.org/r/2955/
Add documentation about how to install and run tests.

This adds some docs on installing dependencies needed to run tests. It's
not totally complete (misses some support for other SCMs), but gives us
a start.

Patch by Craig Silverstein, with some ReST fixes by Christian Hammond.

Reviewed at http://reviews.reviewboard.org/r/2996/
Have --debug set the debug level on the logging module.

When running with --debug, the logging module will now also be set to
show debug messages. This is useful in particular for hg right now, as
we'll get more useful information out of it.

Reviewed at http://reviews.reviewboard.org/r/2997/
Don't lose the fact that tempt_fate returns a value on retries.

The tempt_fate function was at some point modified to return a value,
but this wasn't being honored at one point in the code. Update to return
that value instead of losing it.

Reviewed at http://reviews.reviewboard.org/r/2994/
Fix the GNU diff error to not mention Subversion.

The GNU diff error was specifically saying Subversion was required,
which didn't make sense when other SCMClients triggered the check.
Instead, make the error more generic.
Print debugging info when a subcommand fails, even when ignore_errors is true.

When a subcommand gives an error and ignore_errors is false, we die with
the error output.  But when ignore_errors is true, there's no way to see
the error output, even when running with -d.  This change fixes that but
emitting the error output in debug mode.

I also changed the log messages a bit when running a command, to make it
clear that we're running a subcommand.

Reviewed at http://reviews.reviewboard.org/r/3007/
Ignore warnings when running hg commands.

hg may sometimes emit warnings that are not actually meaningful to the
command being run by post-review.  For instance, my hg will emit the
following for 'hg -q outgoing --template 'b:{branches}\nr:{rev}\n\n'
when run with python2.5:

---
warning: certificate for foo can't be verified (Python too old)"
b:
r:8869
---

This warning is not meaningful, so we just ignore it.

Reviewed at http://reviews.reviewboard.org/r/2995/
Have hg's extract_summary omit the trailing newline.

It's not clear why the code had extract_summary put it in; reviewboard
gives an error if the summary contains newlines.

One of the code-paths that used extract_summary manually stripped the
newline, but two others didn't.

Reviewed at http://reviews.reviewboard.org/r/3019/
Merge branch 'master' into api