Add support for downloading patches and parsed diff data in the API.

Review Request #1642 — Created June 7, 2010 and submitted


Review Board


Add support for downloading patches and parsed diff data in the API.

This adds support for new mimetypes to FileDiffResource and DiffSetResource.
Both now support the text/x-patch mimetype, and will return the stored
patch. In the case of FileDiffResource, it's the patch for that particular
file, and for DiffSetResource, it's the patch for all files in the diff.

FileDiffResource also supports new
application/ and
application/ mimetypes, which return
the parsed diff data in JSON or XML formats. This includes the
insert/delete/replace lines, move information, and more. It also supports a
?syntax-highlighting=1 parameter for returning data in a form that can
have CSS rules applied for syntax highlighting.

This new diff data resource should make it possible for third party
applications to render diffs without reimplementing Review Board's
diff viewer logic.
Tested each resource using curl in order to see the various forms of output.
  2. reviewboard/webapi/ (Diff revision 1)
    Hold up - if you're returning something right off the bat here, what's the rest of the method supposed to do?  Or did I miss something?
    1. Oops.. That's debugging stuff that wasn't supposed to end up in the review request. I was short-circuiting to test something with Firefox when navigating right to the URL.
  1. Christian:
    Looks OK to me - GETing from http://localhost:8080/api/review-requests/2/diffs/1/ with text/x-patch as the Accept in the header correctly gets me the patch.
    However, GETing from http://localhost:8080/api/review-requests/2/diffs/1/files/2/ with text/x-patch as the Accept in header gives me a big JSON string (see: is strange, because I *think* I'm suppose to get the patch for a particular file.
    Could be I'm not using curl correctly.  Anyhow, just a heads up.
Review request changed

Change Summary:

For real this time.


Revision 3 (+127 -2)

Show changes

  2. reviewboard/webapi/ (Diff revision 3)

    1. It's the standard for custom vendor-specific mimetypes for REST data. Prefix with application/
    2. Okay, ship it.