Fossil SCM

Added --html|-h option to /json/diff to retrieve HTML-marked-up diffs.

stephan 2012-03-25 03:23 trunk
Commit a15214e83c3adb3ee02ccae0d06330e3636dbef6
1 file changed +9 -3
+9 -3
--- src/json_diff.c
+++ src/json_diff.c
@@ -29,20 +29,24 @@
2929
** Generates a diff between two versions (zFrom and zTo), using nContext
3030
** content lines in the output. On success, returns a new JSON String
3131
** object. On error it sets g.json's error state and returns NULL.
3232
**
3333
** If fSbs is true (non-0) them side-by-side diffs are used.
34
+**
35
+** If fHtml is true then HTML markup is added to the diff.
3436
*/
3537
cson_value * json_generate_diff(const char *zFrom, const char *zTo,
36
- int nContext, char fSbs){
38
+ int nContext, char fSbs,
39
+ char fHtml){
3740
int fromid;
3841
int toid;
3942
int outLen;
4043
Blob from = empty_blob, to = empty_blob, out = empty_blob;
4144
cson_value * rc = NULL;
4245
int flags = (DIFF_CONTEXT_MASK & nContext)
43
- | (fSbs ? DIFF_SIDEBYSIDE : 0);
46
+ | (fSbs ? DIFF_SIDEBYSIDE : 0)
47
+ | (fHtml ? DIFF_HTML : 0);
4448
fromid = name_to_typed_rid(zFrom, "*");
4549
if(fromid<=0){
4650
json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
4751
"Could not resolve 'from' ID.");
4852
return NULL;
@@ -85,10 +89,11 @@
8589
cson_value * v = NULL;
8690
char const * zFrom;
8791
char const * zTo;
8892
int nContext = 0;
8993
char doSBS;
94
+ char doHtml;
9095
if(!g.perm.Read){
9196
json_set_err(FSL_JSON_E_DENIED,
9297
"Requires 'o' permissions.");
9398
return NULL;
9499
}
@@ -110,11 +115,12 @@
110115
"Required 'v2' parameter is missing.");
111116
return NULL;
112117
}
113118
nContext = json_find_option_int("context",NULL,"c",5);
114119
doSBS = json_find_option_bool("sbs",NULL,"y",0);
115
- v = json_generate_diff(zFrom, zTo, nContext, doSBS);
120
+ doHtml = json_find_option_bool("html",NULL,"h",0);
121
+ v = json_generate_diff(zFrom, zTo, nContext, doSBS, doHtml);
116122
if(!v){
117123
if(!g.json.resultCode){
118124
json_set_err(FSL_JSON_E_UNKNOWN,
119125
"Generating diff failed for unknown reason.");
120126
}
121127
--- src/json_diff.c
+++ src/json_diff.c
@@ -29,20 +29,24 @@
29 ** Generates a diff between two versions (zFrom and zTo), using nContext
30 ** content lines in the output. On success, returns a new JSON String
31 ** object. On error it sets g.json's error state and returns NULL.
32 **
33 ** If fSbs is true (non-0) them side-by-side diffs are used.
 
 
34 */
35 cson_value * json_generate_diff(const char *zFrom, const char *zTo,
36 int nContext, char fSbs){
 
37 int fromid;
38 int toid;
39 int outLen;
40 Blob from = empty_blob, to = empty_blob, out = empty_blob;
41 cson_value * rc = NULL;
42 int flags = (DIFF_CONTEXT_MASK & nContext)
43 | (fSbs ? DIFF_SIDEBYSIDE : 0);
 
44 fromid = name_to_typed_rid(zFrom, "*");
45 if(fromid<=0){
46 json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
47 "Could not resolve 'from' ID.");
48 return NULL;
@@ -85,10 +89,11 @@
85 cson_value * v = NULL;
86 char const * zFrom;
87 char const * zTo;
88 int nContext = 0;
89 char doSBS;
 
90 if(!g.perm.Read){
91 json_set_err(FSL_JSON_E_DENIED,
92 "Requires 'o' permissions.");
93 return NULL;
94 }
@@ -110,11 +115,12 @@
110 "Required 'v2' parameter is missing.");
111 return NULL;
112 }
113 nContext = json_find_option_int("context",NULL,"c",5);
114 doSBS = json_find_option_bool("sbs",NULL,"y",0);
115 v = json_generate_diff(zFrom, zTo, nContext, doSBS);
 
116 if(!v){
117 if(!g.json.resultCode){
118 json_set_err(FSL_JSON_E_UNKNOWN,
119 "Generating diff failed for unknown reason.");
120 }
121
--- src/json_diff.c
+++ src/json_diff.c
@@ -29,20 +29,24 @@
29 ** Generates a diff between two versions (zFrom and zTo), using nContext
30 ** content lines in the output. On success, returns a new JSON String
31 ** object. On error it sets g.json's error state and returns NULL.
32 **
33 ** If fSbs is true (non-0) them side-by-side diffs are used.
34 **
35 ** If fHtml is true then HTML markup is added to the diff.
36 */
37 cson_value * json_generate_diff(const char *zFrom, const char *zTo,
38 int nContext, char fSbs,
39 char fHtml){
40 int fromid;
41 int toid;
42 int outLen;
43 Blob from = empty_blob, to = empty_blob, out = empty_blob;
44 cson_value * rc = NULL;
45 int flags = (DIFF_CONTEXT_MASK & nContext)
46 | (fSbs ? DIFF_SIDEBYSIDE : 0)
47 | (fHtml ? DIFF_HTML : 0);
48 fromid = name_to_typed_rid(zFrom, "*");
49 if(fromid<=0){
50 json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
51 "Could not resolve 'from' ID.");
52 return NULL;
@@ -85,10 +89,11 @@
89 cson_value * v = NULL;
90 char const * zFrom;
91 char const * zTo;
92 int nContext = 0;
93 char doSBS;
94 char doHtml;
95 if(!g.perm.Read){
96 json_set_err(FSL_JSON_E_DENIED,
97 "Requires 'o' permissions.");
98 return NULL;
99 }
@@ -110,11 +115,12 @@
115 "Required 'v2' parameter is missing.");
116 return NULL;
117 }
118 nContext = json_find_option_int("context",NULL,"c",5);
119 doSBS = json_find_option_bool("sbs",NULL,"y",0);
120 doHtml = json_find_option_bool("html",NULL,"h",0);
121 v = json_generate_diff(zFrom, zTo, nContext, doSBS, doHtml);
122 if(!v){
123 if(!g.json.resultCode){
124 json_set_err(FSL_JSON_E_UNKNOWN,
125 "Generating diff failed for unknown reason.");
126 }
127

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button