Jump to >

Diff Resource

Provides information on a collection of complete diffs.

Each diff contains individual per-file diffs as child resources. A diff is revisioned, and more than one can be associated with any particular review request.

Details

Name diff
URI /api/review-requests/{review_request_id}/diffs/{diff_revision}/
Token Policy ID diff
HTTP Methods
  • GET - Returns the information or contents on a particular diff.
  • PUT - Updates a diff.
Parent Resource Diff List Resource
Child Resources
Anonymous Access Yes, if anonymous site access is enabled

Fields

base_commit_idString

The ID/revision this change is built upon. If using a parent diff, then this is the base for that diff. This may not be provided for all diffs or repository types, depending on how the diff was uploaded.

Added in 1.7.13

basedirString

The base directory that will prepended to all paths in the diff. This is needed for some types of repositories. The directory must be between the root of the repository and the top directory referenced in the diff paths.

Added in 1.7

extra_dataDictionary

Extra data as part of the diff. This can be set by the API or extensions.

Added in 2.0

idInteger The numeric ID of the diff.
nameString The name of the diff, usually the filename.
repositoryRepository Resource The repository that the diff is applied against.
revisionInteger The revision of the diff. Starts at 1 for public diffs. Draft diffs may be at 0.
timestampString The date and time that the diff was uploaded (in YYYY-MM-DD HH:MM:SS format).

HTTP GET

Returns the information or contents on a particular diff.

The output varies by mimetype.

If application/json or application/xml is used, then the fields for the diff are returned, like with any other resource.

If text/x-patch is used, then the actual diff file itself is returned. This diff should be as it was when uploaded originally, with potentially some extra SCM-specific headers stripped. The contents will contain that of all per-file diffs that make up this diff.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in

HTTP PUT

Updates a diff.

This is used solely for updating extra data on a diff. The contents of a diff cannot be modified.

Extra data can be stored on the diff for later lookup by passing extra_data.key_name=value. The key_name and value can be any valid strings. Passing a blank value will remove the key. The extra_data. prefix is required.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in
105 - Invalid Form DataHTTP 400 - Bad Request One or more fields had errors

Examples

text/x-patch

$ curl http://reviews.example.com/api/review-requests/8/diffs/1/ -H "Accept: text/x-patch"
Last-Modified: Wed, 25 Feb 2009 02:01:21 GMT
Content-Type: text/x-patch
Content-Disposition: inline; filename=bug.patch
Vary: Accept, Cookie
Index: /trunk/reviewboard/settings_local.py.tmpl
===================================================================
--- /trunk/reviewboard/settings_local.py.tmpl	(revision 1797)
+++ /trunk/reviewboard/settings_local.py.tmpl	(working copy)
@@ -13,15 +13,15 @@
 # django installations, the best option is probably to use memcached.
 CACHE_BACKEND = 'locmem:///'
 
-# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'US/Pacific'
-
 # Language code for this installation. All choices can be found here:
 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
 LANGUAGE_CODE = 'en-us'
 
+# Local time zone for this installation. All choices can be found here:
+# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+TIME_ZONE = 'US/Pacific'
+
 # This should match the ID of the Site object in the database.  This is used to
 # figure out URLs to stick in e-mails and related pages.
 SITE_ID = 1
@@ -34,7 +34,6 @@
 # to load the internationalization machinery.
 USE_I18N = True
 
-
 # TLS for LDAP.  If you're using LDAP authentication and your LDAP server
 # doesn't support ldaps://, you can enable start-TLS with this.
 LDAP_TLS = False
Index: TESTING
===================================================================
--- TESTING	(revision 0)
+++ TESTING	(revision 0)
@@ -0,0 +1 @@
+This is a test!

application/vnd.reviewboard.org.diff+json

$ curl http://reviews.example.com/api/review-requests/8/diffs/1/ -H "Accept: application/json"
Last-Modified: Wed, 25 Feb 2009 02:01:21 GMT
ETag: e58e81678c35571c0dfc098aa48170472838db26
Content-Type: application/vnd.reviewboard.org.diff+json
X-Content-Type-Options: nosniff
Vary: Accept, Cookie
{
  "diff": {
    "base_commit_id": null, 
    "basedir": "", 
    "extra_data": {}, 
    "id": 8, 
    "links": {
      "files": {
        "href": "http://reviews.example.com/api/review-requests/8/diffs/1/files/", 
        "method": "GET"
      }, 
      "repository": {
        "href": "http://reviews.example.com/api/repositories/1/", 
        "method": "GET", 
        "title": "Review Board SVN"
      }, 
      "self": {
        "href": "http://reviews.example.com/api/review-requests/8/diffs/1/", 
        "method": "GET"
      }, 
      "update": {
        "href": "http://reviews.example.com/api/review-requests/8/diffs/1/", 
        "method": "PUT"
      }
    }, 
    "name": "diff", 
    "revision": 1, 
    "timestamp": "2009-02-25T02:01:21Z"
  }, 
  "stat": "ok"
}