Refactor capabilities and fix bug

There was a bug with capabilities not being initialized when they were
used due to the server being contacted after diff generation. The
server is now contacted and the capabilities downloaded before a diff
is generated. This makes it that post-review must contact the Review
Board server even when only generating diffs, so diffs may no longer
be generated offline.

The way capabilities were passed to the SCM tools needed to be
refactored to support the new rbt commands. Capabilities were being
attached to the server object and being passed to the tool, but since
the server object is no longer present in the new commands this had to
change. The Capabilities object itself is now passed directly to the
tools.
Refactor p4 invocation from PerforceClient, and add unit tests.

In an effort to clean up PerforceClient a little and make it testable,
this change consolidates all the p4 invocation into a class called
P4Wrapper. A P4Wrapper class is passed to PerforceClient (defaults to
P4Wrapper, but unit tests can override this), and an instance will be
created from this. Callers can call into this and just deal with the
results, regardless of how p4 is called.

This allowed some unit tests to be written. While this is by no means
comprehensive, it does add some basic testing for things like old-style
and new-style Perforce counters, get_repository_info, and basic diff
building.

I'll be making use of these new tests for Perforce moved file support.

Going forward, we probably should look into using p4 -G to get
marshalled Python objects as results from the commands (in order to
avoid doing our own parsing), and add some exceptions for failure so
that PerforceClient doesn't have to parse error strings.
Fix running Perforce commands with -G.

The -G parameter was being passed after the arguments to p4, rather than
right after p4, which is required. This reorders things to pass -G
first.
Generate proper diffs with moved file information for Perforce.

Modern versions of Perforce support file move operations. These may
either be straight moves, or moves with file changes. We now handle this
information and diff the files correctly. We also inject some custom
fields indicating the move information, so it can be processed by
Review Board.

This feature is funded by NetApp, Inc.
Fix port splitting logic to accomodate ssl: repositories for perforce.

If the perforce server uses ssl, there will be two colons in the P4PORT path
specifier. This would break our port-splitting logic.

Fixes bug 2572.
Reviewed at http://reviews.reviewboard.org/r/3719/