| | @@ -162,18 +162,13 @@ |
| 162 | 162 | } |
| 163 | 163 | fossil_free(z); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /* |
| 167 | | -** Default header text for diff with --webpage |
| 167 | +** Extra CSS for side-by-side diffs |
| 168 | 168 | */ |
| 169 | | -static const char zWebpageHdr[] = |
| 170 | | -@ <!DOCTYPE html> |
| 171 | | -@ <html> |
| 172 | | -@ <head> |
| 173 | | -@ <meta charset="UTF-8"> |
| 174 | | -@ <style> |
| 169 | +static const char zSbsCss[] = |
| 175 | 170 | @ table.sbsdiffcols { |
| 176 | 171 | @ width: 90%; |
| 177 | 172 | @ border-spacing: 0; |
| 178 | 173 | @ font-size: xx-small; |
| 179 | 174 | @ } |
| | @@ -199,11 +194,22 @@ |
| 199 | 194 | @ overflow-x: auto; |
| 200 | 195 | @ } |
| 201 | 196 | @ div.diffmkrcol { |
| 202 | 197 | @ padding: 0 1em; |
| 203 | 198 | @ } |
| 204 | | -@ span.diffchng { |
| 199 | +; |
| 200 | + |
| 201 | +/* |
| 202 | +** Default header text for diff with --webpage |
| 203 | +*/ |
| 204 | +static const char zWebpageHdr[] = |
| 205 | +@ <!DOCTYPE html> |
| 206 | +@ <html> |
| 207 | +@ <head> |
| 208 | +@ <meta charset="UTF-8"> |
| 209 | +@ <style> |
| 210 | +@ %sspan.diffchng { |
| 205 | 211 | @ background-color: #c0c0ff; |
| 206 | 212 | @ } |
| 207 | 213 | @ span.diffadd { |
| 208 | 214 | @ background-color: #c0ffc0; |
| 209 | 215 | @ } |
| | @@ -226,40 +232,34 @@ |
| 226 | 232 | @ </body> |
| 227 | 233 | @ </html> |
| 228 | 234 | ; |
| 229 | 235 | |
| 230 | 236 | /* |
| 231 | | -** Print a header or footer on the overall diff output. |
| 232 | | -** |
| 233 | | -** This is only a factor for --webpage, in which case the header |
| 234 | | -** is the HTML header CSS definitions and the footer is the HTML |
| 235 | | -** close tags. |
| 237 | +** Do preliminary output before computing a diff. |
| 236 | 238 | */ |
| 237 | | -void diff_header(u64 diffFlags, Blob *pOut){ |
| 239 | +void diff_begin(u64 diffFlags){ |
| 238 | 240 | if( (diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 239 | | - if( pOut ){ |
| 240 | | - blob_append(pOut, zWebpageHdr, -1); |
| 241 | + const char *zExtra; |
| 242 | + if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 243 | + zExtra = zSbsCss; |
| 241 | 244 | }else{ |
| 242 | | - fossil_print("%s", zWebpageHdr); |
| 245 | + zExtra = ""; |
| 243 | 246 | } |
| 247 | + fossil_print(zWebpageHdr/*works-like:"%s"*/, zExtra); |
| 244 | 248 | } |
| 245 | 249 | } |
| 246 | | -void diff_footer(u64 diffFlags, Blob *pOut){ |
| 250 | + |
| 251 | +/* Do any final output required by a diff and complete the diff |
| 252 | +** process. |
| 253 | +*/ |
| 254 | +void diff_end(u64 diffFlags, int nErr){ |
| 247 | 255 | if( (diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 248 | 256 | if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 249 | 257 | const unsigned char *zJs = builtin_file("sbsdiff.js", 0); |
| 250 | | - if( pOut ){ |
| 251 | | - blob_appendf(pOut, "<script>\n%s</script>\n", zJs); |
| 252 | | - }else{ |
| 253 | | - fossil_print("<script>\n%s</script>\n", zJs); |
| 254 | | - } |
| 255 | | - } |
| 256 | | - if( pOut ){ |
| 257 | | - blob_append(pOut, zWebpageEnd, -1); |
| 258 | | - }else{ |
| 259 | | - fossil_print("%s", zWebpageEnd); |
| 260 | | - } |
| 258 | + fossil_print("<script>\n%s</script>\n", zJs); |
| 259 | + } |
| 260 | + fossil_print("%s", zWebpageEnd); |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /* |
| 265 | 265 | ** Show the difference between two files, one in memory and one on disk. |
| | @@ -1058,11 +1058,11 @@ |
| 1058 | 1058 | ridTo); |
| 1059 | 1059 | if( zFrom==0 ){ |
| 1060 | 1060 | fossil_fatal("check-in %s has no parent", zTo); |
| 1061 | 1061 | } |
| 1062 | 1062 | } |
| 1063 | | - diff_header(diffFlags, 0); |
| 1063 | + diff_begin(diffFlags); |
| 1064 | 1064 | if( againstUndo ){ |
| 1065 | 1065 | if( db_lget_int("undo_available",0)==0 ){ |
| 1066 | 1066 | fossil_print("No undo or redo is available\n"); |
| 1067 | 1067 | return; |
| 1068 | 1068 | } |
| | @@ -1086,11 +1086,11 @@ |
| 1086 | 1086 | } |
| 1087 | 1087 | fossil_free(pFileDir[i].zName); |
| 1088 | 1088 | } |
| 1089 | 1089 | fossil_free(pFileDir); |
| 1090 | 1090 | } |
| 1091 | | - diff_footer(diffFlags, 0); |
| 1091 | + diff_end(diffFlags, 0); |
| 1092 | 1092 | if ( diffFlags & DIFF_NUMSTAT ){ |
| 1093 | 1093 | fossil_print("%10d %10d TOTAL over %d changed files\n", |
| 1094 | 1094 | g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]); |
| 1095 | 1095 | } |
| 1096 | 1096 | } |
| 1097 | 1097 | |