• 
      

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

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

    Information

    Review Board
    master

    Reviewers

    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/vnd.reviewboard.org.diff.data+json and
    application/vnd.reviewboard.org.diff.data+xml 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.
    mike_conley
    1. 
        
    2. reviewboard/webapi/resources.py (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.
    3. 
        
    mike_conley
    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:  http://www.pastie.org/1002052)...which 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.
      
      -Mike
    2. 
        
    chipx86
    chipx86
    Review request changed
    Change Summary:
    For real this time.
    david
    1. 
        
    2. reviewboard/webapi/resources.py (Diff revision 3)
       
       
      vnd.reviewboard.org?
      1. It's the standard for custom vendor-specific mimetypes for REST data. Prefix with application/vnd.domain.com.
      2. Okay, ship it.
    3.