# HG changeset patch # User Gregory Szorc # Date 1428719962 14400 # Node ID 2f43f8cf82198bbe22826cf84ba8278ee7de2395 # Parent bbf1ae6b6a4405c73b79867f005e00c5018f5ff6 json: implement {filediff} template Single letter properties are used to keep payload size down, as diff representation can be quite large and longer property names can create a lot of extra work for parsers. Rename is not yet captured. This can be done in a follow-up. diff -r bbf1ae6b6a44 -r 2f43f8cf8219 mercurial/templates/json/map --- a/mercurial/templates/json/map Fri Apr 10 22:34:12 2015 -0400 +++ b/mercurial/templates/json/map Fri Apr 10 22:39:22 2015 -0400 @@ -78,7 +78,40 @@ "status": {status|json} }' summary = '"not yet implemented"' -filediff = '"not yet implemented"' +filediff = '\{ + "path": {file|json}, + "node": {node|json}, + "date": {date|json}, + "desc": {desc|json}, + "author": {author|json}, + "parents": [{join(parent%changesetparent, ", ")}], + "children": [{join(child%changesetparent, ", ")}], + "diff": [{join(diff%diffblock, ", ")}] + }' +diffblock = '\{ + "blockno": {blockno|json}, + "lines": [{join(lines, ", ")}] + }' +difflineplus = '\{ + "t": "+", + "n": {lineno|json}, + "l": {line|json} + }' +difflineminus = '\{ + "t": "-", + "n": {lineno|json}, + "l": {line|json} + }' +difflineat = '\{ + "t": "@", + "n": {lineno|json}, + "l": {line|json} + }' +diffline = '\{ + "t": "", + "n": {lineno|json}, + "l": {line|json} + }' filecomparison = '"not yet implemented"' fileannotate = '"not yet implemented"' filelog = '"not yet implemented"' diff -r bbf1ae6b6a44 -r 2f43f8cf8219 tests/test-hgweb-json.t --- a/tests/test-hgweb-json.t Fri Apr 10 22:34:12 2015 -0400 +++ b/tests/test-hgweb-json.t Fri Apr 10 22:39:22 2015 -0400 @@ -678,7 +678,52 @@ $ request json-diff/f8bbb9024b10/foo 200 Script output follows - "not yet implemented" + { + "author": "test", + "children": [], + "date": [ + 0.0, + 0 + ], + "desc": "modify foo", + "diff": [ + { + "blockno": 1, + "lines": [ + { + "l": "--- a/foo\tThu Jan 01 00:00:00 1970 +0000\n", + "n": 1, + "t": "-" + }, + { + "l": "+++ b/foo\tThu Jan 01 00:00:00 1970 +0000\n", + "n": 2, + "t": "+" + }, + { + "l": "@@ -1,1 +1,1 @@\n", + "n": 3, + "t": "@" + }, + { + "l": "-foo\n", + "n": 4, + "t": "-" + }, + { + "l": "+bar\n", + "n": 5, + "t": "+" + } + ] + } + ], + "node": "f8bbb9024b10f93cdbb8d940337398291d40dea8", + "parents": [ + "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e" + ], + "path": "foo" + } comparison/{revision}/{path} shows information about before and after for a file