Add initial web API for commit histories.

Review Request #6816 — Created Jan. 21, 2015 and submitted — Latest diff uploaded

Review Board
6933, 6787, 6931
chipx86, mike_conley, smacleod

Add the DiffCommitResource and DraftDiffCommitResource resources.
The DiffCommitResource is a resource for retrieving the information
about the DiffCommits under a particular DiffSet. The
DraftDiffCommitResource inherits from the DiffCommitResource and
modifies it to allow for the creation of DiffCommits and associated
FileDiffs. The DraftDiffCommitResource handles the uploading of
FileDiffs for DiffCommits instead of the DiffSetResource.

The DiffSetResource POST method now takes an extra optional field,
create_empty, that determines if the DiffSet that is created is
created without uploading a .diff file. This is used in the creation
of review requests with commit histories.

The FileDiffResource and DraftFileDiffResource classes now filter
their results based on the commit query parameter. If no commit query
parameter is given, only those FileDiffs unattached to a
DiffCommit will be return. This filtering is only applied to the
list API, not the item API.

Add a new form, the UploadCommitForm, for handling the processing of
data for creating new DiffCommit instances.

Refactor behaviour for uploading FileDiffs from the DiffSetManager
to a new class, the DiffProcessorMixin. This mix-in handles the
initial processing of .diff files, their comparison (for header vs.
source files), generating file lists, and creating actual FileDiffs
from upload (it calls the child class's implementation of

The DiffSetManager now has a create_empty method for creating
DiffSets without FileDiffs for usage with DiffCommits.

Add the DiffCommitManager model. It inherits from the

Add a WebAPI capability to show that the server supports review
requests with commit histories. This allows new versions of rbt that
support commit histories to create review requests with history by
default if the tool supports it.

Add new unit tests for the web API. The tests include:
- test_filediff, which tests FileDiff filtering of a DiffCommit
- test_draft_diff_commit, which does the base API tests for the
- test_diff_commit, which does the base API tests for the

Unit tests pass.

Did the following manual testing:

  • Created a review request via rbt post. It was automatically
    created with history. (There was one commit under the draft).
  • Able to read the commit list and single commit via the API.
  • Able to filter the FileDiff list resource.
  • The FileDiff item resource was not filtered.
  • Able to publish, discard, and delete the review request.
  • Able to use all the public API endoint functionality of the
    published RR anonymously