Fossil SCM
Add scaffolding for iterating over lists of files for merge-info --html. Simply emit a UL list for the time being.
Commit
8bb036bf9a4eec0ea8ce896e0b0d8b3b0b9d05e585eb04a656edc2cdf71a3e35
Parent
5eac2b1ba16fea4…
1 file changed
+50
+50
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -297,10 +297,60 @@ | ||
| 297 | 297 | int nContext /* Diff context lines */){ |
| 298 | 298 | Blob out = empty_blob; |
| 299 | 299 | |
| 300 | 300 | blob_append(&out, diff_webpage_header(bDark), -1); |
| 301 | 301 | merge_info_html_css(&out); |
| 302 | + | |
| 303 | + if( g.argc==2 ){ | |
| 304 | + /* No files named on the command-line. Use every file mentioned | |
| 305 | + ** in the MERGESTAT table to generate the file list. */ | |
| 306 | + Stmt q; | |
| 307 | + int cnt = 0; | |
| 308 | + db_prepare(&q, | |
| 309 | + "SELECT coalesce(fnr,fn), op FROM mergestat %s ORDER BY 1", | |
| 310 | + bAll ? "" : "WHERE op IN ('MERGE','CONFLICT')" /*safe-for-%s*/ | |
| 311 | + ); | |
| 312 | + blob_append(&out, "<ul>\n", 5); | |
| 313 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 314 | + blob_appendf(&out,"<li>%s ", db_column_text(&q,1)); | |
| 315 | + blob_appendf(&out, "%h</li>\n", db_column_text(&q, 0)); | |
| 316 | + cnt++; | |
| 317 | + } | |
| 318 | + db_finalize(&q); | |
| 319 | + if( cnt==0 ){ | |
| 320 | + blob_append(&out, "<li>No interesting changes in this merge. " | |
| 321 | + "Use --all to see everything</li>\n", | |
| 322 | + -1); | |
| 323 | + } | |
| 324 | + blob_append(&out, "</ul>\n", 6); | |
| 325 | + }else{ | |
| 326 | + int i; | |
| 327 | + /* Use only files named on the command-line in the file list. | |
| 328 | + ** But verify each file named is actually found in the MERGESTAT | |
| 329 | + ** table first. */ | |
| 330 | + blob_append(&out, "<ul>\n", 5); | |
| 331 | + for(i=2; i<g.argc; i++){ | |
| 332 | + char *zFile; /* Input filename */ | |
| 333 | + char *zTreename; /* Name of the file in the tree */ | |
| 334 | + Blob fname; /* Filename relative to root */ | |
| 335 | + char *zOp; /* Operation on this file */ | |
| 336 | + zFile = mprintf("%/", g.argv[i]); | |
| 337 | + file_tree_name(zFile, &fname, 0, 1); | |
| 338 | + fossil_free(zFile); | |
| 339 | + zTreename = blob_str(&fname); | |
| 340 | + zOp = db_text(0, "SELECT op FROM mergestat WHERE fn=%Q or fnr=%Q", | |
| 341 | + zTreename, zTreename); | |
| 342 | + if( !zOp ){ | |
| 343 | + fossil_fatal("Don't have merge info for %s", zTreename); | |
| 344 | + } | |
| 345 | + blob_appendf(&out, "<li>%s ", zOp); | |
| 346 | + fossil_free(zOp); | |
| 347 | + blob_appendf(&out, "%h</li>\n", zTreename); | |
| 348 | + blob_reset(&fname); | |
| 349 | + } | |
| 350 | + blob_append(&out, "</ul>\n", 6); | |
| 351 | + } | |
| 302 | 352 | |
| 303 | 353 | blob_append(&out, diff_webpage_footer(), -1); |
| 304 | 354 | blob_append_char(&out, '\n'); |
| 305 | 355 | blob_write_to_file(&out, "-"); |
| 306 | 356 | blob_reset(&out); |
| 307 | 357 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -297,10 +297,60 @@ | |
| 297 | int nContext /* Diff context lines */){ |
| 298 | Blob out = empty_blob; |
| 299 | |
| 300 | blob_append(&out, diff_webpage_header(bDark), -1); |
| 301 | merge_info_html_css(&out); |
| 302 | |
| 303 | blob_append(&out, diff_webpage_footer(), -1); |
| 304 | blob_append_char(&out, '\n'); |
| 305 | blob_write_to_file(&out, "-"); |
| 306 | blob_reset(&out); |
| 307 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -297,10 +297,60 @@ | |
| 297 | int nContext /* Diff context lines */){ |
| 298 | Blob out = empty_blob; |
| 299 | |
| 300 | blob_append(&out, diff_webpage_header(bDark), -1); |
| 301 | merge_info_html_css(&out); |
| 302 | |
| 303 | if( g.argc==2 ){ |
| 304 | /* No files named on the command-line. Use every file mentioned |
| 305 | ** in the MERGESTAT table to generate the file list. */ |
| 306 | Stmt q; |
| 307 | int cnt = 0; |
| 308 | db_prepare(&q, |
| 309 | "SELECT coalesce(fnr,fn), op FROM mergestat %s ORDER BY 1", |
| 310 | bAll ? "" : "WHERE op IN ('MERGE','CONFLICT')" /*safe-for-%s*/ |
| 311 | ); |
| 312 | blob_append(&out, "<ul>\n", 5); |
| 313 | while( db_step(&q)==SQLITE_ROW ){ |
| 314 | blob_appendf(&out,"<li>%s ", db_column_text(&q,1)); |
| 315 | blob_appendf(&out, "%h</li>\n", db_column_text(&q, 0)); |
| 316 | cnt++; |
| 317 | } |
| 318 | db_finalize(&q); |
| 319 | if( cnt==0 ){ |
| 320 | blob_append(&out, "<li>No interesting changes in this merge. " |
| 321 | "Use --all to see everything</li>\n", |
| 322 | -1); |
| 323 | } |
| 324 | blob_append(&out, "</ul>\n", 6); |
| 325 | }else{ |
| 326 | int i; |
| 327 | /* Use only files named on the command-line in the file list. |
| 328 | ** But verify each file named is actually found in the MERGESTAT |
| 329 | ** table first. */ |
| 330 | blob_append(&out, "<ul>\n", 5); |
| 331 | for(i=2; i<g.argc; i++){ |
| 332 | char *zFile; /* Input filename */ |
| 333 | char *zTreename; /* Name of the file in the tree */ |
| 334 | Blob fname; /* Filename relative to root */ |
| 335 | char *zOp; /* Operation on this file */ |
| 336 | zFile = mprintf("%/", g.argv[i]); |
| 337 | file_tree_name(zFile, &fname, 0, 1); |
| 338 | fossil_free(zFile); |
| 339 | zTreename = blob_str(&fname); |
| 340 | zOp = db_text(0, "SELECT op FROM mergestat WHERE fn=%Q or fnr=%Q", |
| 341 | zTreename, zTreename); |
| 342 | if( !zOp ){ |
| 343 | fossil_fatal("Don't have merge info for %s", zTreename); |
| 344 | } |
| 345 | blob_appendf(&out, "<li>%s ", zOp); |
| 346 | fossil_free(zOp); |
| 347 | blob_appendf(&out, "%h</li>\n", zTreename); |
| 348 | blob_reset(&fname); |
| 349 | } |
| 350 | blob_append(&out, "</ul>\n", 6); |
| 351 | } |
| 352 | |
| 353 | blob_append(&out, diff_webpage_footer(), -1); |
| 354 | blob_append_char(&out, '\n'); |
| 355 | blob_write_to_file(&out, "-"); |
| 356 | blob_reset(&out); |
| 357 |