Fossil SCM
Initial empty scaffolding for merge-info --html/--browser options. There is still much to do here.
Commit
ca7eceb92cb79156419addd6c8419e7366832fcdb4cf888d6b3f22043727a01e
Parent
aeec557e897f2af…
1 file changed
+21
-7
+21
-7
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -192,11 +192,11 @@ | ||
| 192 | 192 | sz = db_column_int(&q, 4); |
| 193 | 193 | if( rid==0 && sz>0 ){ |
| 194 | 194 | /* The origin file had been edited so we'll have to pull its |
| 195 | 195 | ** original content out of the undo buffer */ |
| 196 | 196 | Stmt q2; |
| 197 | - db_prepare(&q2, | |
| 197 | + db_prepare(&q2, | |
| 198 | 198 | "SELECT content FROM undo" |
| 199 | 199 | " WHERE pathname=%Q AND octet_length(content)=%d", |
| 200 | 200 | zFN, sz |
| 201 | 201 | ); |
| 202 | 202 | blob_zero(&v1); |
| @@ -231,10 +231,17 @@ | ||
| 231 | 231 | blob_reset(&v1); |
| 232 | 232 | blob_reset(&v2); |
| 233 | 233 | blob_reset(&out); |
| 234 | 234 | db_finalize(&q); |
| 235 | 235 | } |
| 236 | + | |
| 237 | +static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */ | |
| 238 | + int bDark, /* use dark mode */ | |
| 239 | + int bAll, /* All changes, not just merged content */ | |
| 240 | + int nContext /* Diff context lines */){ | |
| 241 | + /* TODO */ | |
| 242 | +} | |
| 236 | 243 | |
| 237 | 244 | /* |
| 238 | 245 | ** COMMAND: merge-info |
| 239 | 246 | ** |
| 240 | 247 | ** Usage: %fossil merge-info [OPTIONS] |
| @@ -242,27 +249,30 @@ | ||
| 242 | 249 | ** Display information about the most recent merge operation. |
| 243 | 250 | ** |
| 244 | 251 | ** Options: |
| 245 | 252 | ** -a|--all Show all file changes that happened because of |
| 246 | 253 | ** the merge. Normally only MERGE, CONFLICT, and ERROR |
| 247 | -** lines are shown | |
| 254 | +** lines are shown. | |
| 248 | 255 | ** -c|--context N Show N lines of context around each change, |
| 249 | 256 | ** with negative N meaning show all content. Only |
| 250 | 257 | ** meaningful in combination with --tcl or --tk. |
| 251 | -** --dark Use dark mode for the Tcl/Tk-based GUI | |
| 258 | +** --dark Use dark mode for the Tcl/Tk/HTML output modes. | |
| 252 | 259 | ** --tcl FILE Generate (to stdout) a TCL list containing |
| 253 | 260 | ** information needed to display the changes to |
| 254 | 261 | ** FILE caused by the most recent merge. FILE must |
| 255 | 262 | ** be a pathname relative to the root of the check-out. |
| 256 | 263 | ** --tk Bring up a Tcl/Tk GUI that shows the changes |
| 257 | 264 | ** associated with the most recent merge. |
| 258 | -** | |
| 265 | +** --html Like --tk but emits HTML to stdout. | |
| 266 | +** -b|--browser Like --html but show the result in a web browser. | |
| 259 | 267 | */ |
| 260 | 268 | void merge_info_cmd(void){ |
| 261 | 269 | const char *zCnt; |
| 262 | 270 | const char *zTcl; |
| 263 | 271 | int bTk; |
| 272 | + int bBrowser; | |
| 273 | + int bHtml; | |
| 264 | 274 | int bDark; |
| 265 | 275 | int bAll; |
| 266 | 276 | int nContext; |
| 267 | 277 | Stmt q; |
| 268 | 278 | const char *zWhere; |
| @@ -269,14 +279,16 @@ | ||
| 269 | 279 | int cnt = 0; |
| 270 | 280 | |
| 271 | 281 | db_must_be_within_tree(); |
| 272 | 282 | zTcl = find_option("tcl", 0, 1); |
| 273 | 283 | bTk = find_option("tk", 0, 0)!=0; |
| 284 | + bBrowser = find_option("browser", "b", 0)!=0; | |
| 285 | + bHtml = find_option("html", 0, 0)!=0 || bBrowser; | |
| 274 | 286 | zCnt = find_option("context", "c", 1); |
| 275 | 287 | bDark = find_option("dark", 0, 0)!=0; |
| 276 | 288 | bAll = find_option("all", "a", 0)!=0; |
| 277 | - if( bTk==0 ){ | |
| 289 | + if( (bTk + bHtml)==0 ){ | |
| 278 | 290 | verify_all_options(); |
| 279 | 291 | if( g.argc>2 ){ |
| 280 | 292 | usage("[OPTIONS]"); |
| 281 | 293 | } |
| 282 | 294 | } |
| @@ -295,12 +307,14 @@ | ||
| 295 | 307 | return; |
| 296 | 308 | } |
| 297 | 309 | if( bTk ){ |
| 298 | 310 | merge_info_tk(bDark, bAll, nContext); |
| 299 | 311 | return; |
| 300 | - } | |
| 301 | - if( zTcl ){ | |
| 312 | + }else if( bHtml ){ | |
| 313 | + merge_info_html(bBrowser, bDark, bAll, nContext); | |
| 314 | + return; | |
| 315 | + }else if( zTcl ){ | |
| 302 | 316 | merge_info_tcl(zTcl, nContext); |
| 303 | 317 | return; |
| 304 | 318 | } |
| 305 | 319 | if( bAll ){ |
| 306 | 320 | zWhere = ""; |
| 307 | 321 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -192,11 +192,11 @@ | |
| 192 | sz = db_column_int(&q, 4); |
| 193 | if( rid==0 && sz>0 ){ |
| 194 | /* The origin file had been edited so we'll have to pull its |
| 195 | ** original content out of the undo buffer */ |
| 196 | Stmt q2; |
| 197 | db_prepare(&q2, |
| 198 | "SELECT content FROM undo" |
| 199 | " WHERE pathname=%Q AND octet_length(content)=%d", |
| 200 | zFN, sz |
| 201 | ); |
| 202 | blob_zero(&v1); |
| @@ -231,10 +231,17 @@ | |
| 231 | blob_reset(&v1); |
| 232 | blob_reset(&v2); |
| 233 | blob_reset(&out); |
| 234 | db_finalize(&q); |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | ** COMMAND: merge-info |
| 239 | ** |
| 240 | ** Usage: %fossil merge-info [OPTIONS] |
| @@ -242,27 +249,30 @@ | |
| 242 | ** Display information about the most recent merge operation. |
| 243 | ** |
| 244 | ** Options: |
| 245 | ** -a|--all Show all file changes that happened because of |
| 246 | ** the merge. Normally only MERGE, CONFLICT, and ERROR |
| 247 | ** lines are shown |
| 248 | ** -c|--context N Show N lines of context around each change, |
| 249 | ** with negative N meaning show all content. Only |
| 250 | ** meaningful in combination with --tcl or --tk. |
| 251 | ** --dark Use dark mode for the Tcl/Tk-based GUI |
| 252 | ** --tcl FILE Generate (to stdout) a TCL list containing |
| 253 | ** information needed to display the changes to |
| 254 | ** FILE caused by the most recent merge. FILE must |
| 255 | ** be a pathname relative to the root of the check-out. |
| 256 | ** --tk Bring up a Tcl/Tk GUI that shows the changes |
| 257 | ** associated with the most recent merge. |
| 258 | ** |
| 259 | */ |
| 260 | void merge_info_cmd(void){ |
| 261 | const char *zCnt; |
| 262 | const char *zTcl; |
| 263 | int bTk; |
| 264 | int bDark; |
| 265 | int bAll; |
| 266 | int nContext; |
| 267 | Stmt q; |
| 268 | const char *zWhere; |
| @@ -269,14 +279,16 @@ | |
| 269 | int cnt = 0; |
| 270 | |
| 271 | db_must_be_within_tree(); |
| 272 | zTcl = find_option("tcl", 0, 1); |
| 273 | bTk = find_option("tk", 0, 0)!=0; |
| 274 | zCnt = find_option("context", "c", 1); |
| 275 | bDark = find_option("dark", 0, 0)!=0; |
| 276 | bAll = find_option("all", "a", 0)!=0; |
| 277 | if( bTk==0 ){ |
| 278 | verify_all_options(); |
| 279 | if( g.argc>2 ){ |
| 280 | usage("[OPTIONS]"); |
| 281 | } |
| 282 | } |
| @@ -295,12 +307,14 @@ | |
| 295 | return; |
| 296 | } |
| 297 | if( bTk ){ |
| 298 | merge_info_tk(bDark, bAll, nContext); |
| 299 | return; |
| 300 | } |
| 301 | if( zTcl ){ |
| 302 | merge_info_tcl(zTcl, nContext); |
| 303 | return; |
| 304 | } |
| 305 | if( bAll ){ |
| 306 | zWhere = ""; |
| 307 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -192,11 +192,11 @@ | |
| 192 | sz = db_column_int(&q, 4); |
| 193 | if( rid==0 && sz>0 ){ |
| 194 | /* The origin file had been edited so we'll have to pull its |
| 195 | ** original content out of the undo buffer */ |
| 196 | Stmt q2; |
| 197 | db_prepare(&q2, |
| 198 | "SELECT content FROM undo" |
| 199 | " WHERE pathname=%Q AND octet_length(content)=%d", |
| 200 | zFN, sz |
| 201 | ); |
| 202 | blob_zero(&v1); |
| @@ -231,10 +231,17 @@ | |
| 231 | blob_reset(&v1); |
| 232 | blob_reset(&v2); |
| 233 | blob_reset(&out); |
| 234 | db_finalize(&q); |
| 235 | } |
| 236 | |
| 237 | static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */ |
| 238 | int bDark, /* use dark mode */ |
| 239 | int bAll, /* All changes, not just merged content */ |
| 240 | int nContext /* Diff context lines */){ |
| 241 | /* TODO */ |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | ** COMMAND: merge-info |
| 246 | ** |
| 247 | ** Usage: %fossil merge-info [OPTIONS] |
| @@ -242,27 +249,30 @@ | |
| 249 | ** Display information about the most recent merge operation. |
| 250 | ** |
| 251 | ** Options: |
| 252 | ** -a|--all Show all file changes that happened because of |
| 253 | ** the merge. Normally only MERGE, CONFLICT, and ERROR |
| 254 | ** lines are shown. |
| 255 | ** -c|--context N Show N lines of context around each change, |
| 256 | ** with negative N meaning show all content. Only |
| 257 | ** meaningful in combination with --tcl or --tk. |
| 258 | ** --dark Use dark mode for the Tcl/Tk/HTML output modes. |
| 259 | ** --tcl FILE Generate (to stdout) a TCL list containing |
| 260 | ** information needed to display the changes to |
| 261 | ** FILE caused by the most recent merge. FILE must |
| 262 | ** be a pathname relative to the root of the check-out. |
| 263 | ** --tk Bring up a Tcl/Tk GUI that shows the changes |
| 264 | ** associated with the most recent merge. |
| 265 | ** --html Like --tk but emits HTML to stdout. |
| 266 | ** -b|--browser Like --html but show the result in a web browser. |
| 267 | */ |
| 268 | void merge_info_cmd(void){ |
| 269 | const char *zCnt; |
| 270 | const char *zTcl; |
| 271 | int bTk; |
| 272 | int bBrowser; |
| 273 | int bHtml; |
| 274 | int bDark; |
| 275 | int bAll; |
| 276 | int nContext; |
| 277 | Stmt q; |
| 278 | const char *zWhere; |
| @@ -269,14 +279,16 @@ | |
| 279 | int cnt = 0; |
| 280 | |
| 281 | db_must_be_within_tree(); |
| 282 | zTcl = find_option("tcl", 0, 1); |
| 283 | bTk = find_option("tk", 0, 0)!=0; |
| 284 | bBrowser = find_option("browser", "b", 0)!=0; |
| 285 | bHtml = find_option("html", 0, 0)!=0 || bBrowser; |
| 286 | zCnt = find_option("context", "c", 1); |
| 287 | bDark = find_option("dark", 0, 0)!=0; |
| 288 | bAll = find_option("all", "a", 0)!=0; |
| 289 | if( (bTk + bHtml)==0 ){ |
| 290 | verify_all_options(); |
| 291 | if( g.argc>2 ){ |
| 292 | usage("[OPTIONS]"); |
| 293 | } |
| 294 | } |
| @@ -295,12 +307,14 @@ | |
| 307 | return; |
| 308 | } |
| 309 | if( bTk ){ |
| 310 | merge_info_tk(bDark, bAll, nContext); |
| 311 | return; |
| 312 | }else if( bHtml ){ |
| 313 | merge_info_html(bBrowser, bDark, bAll, nContext); |
| 314 | return; |
| 315 | }else if( zTcl ){ |
| 316 | merge_info_tcl(zTcl, nContext); |
| 317 | return; |
| 318 | } |
| 319 | if( bAll ){ |
| 320 | zWhere = ""; |
| 321 |