Fossil SCM

Initial empty scaffolding for merge-info --html/--browser options. There is still much to do here.

stephan 2024-12-06 23:46 trunk
Commit ca7eceb92cb79156419addd6c8419e7366832fcdb4cf888d6b3f22043727a01e
1 file changed +21 -7
+21 -7
--- src/merge.c
+++ src/merge.c
@@ -192,11 +192,11 @@
192192
sz = db_column_int(&q, 4);
193193
if( rid==0 && sz>0 ){
194194
/* The origin file had been edited so we'll have to pull its
195195
** original content out of the undo buffer */
196196
Stmt q2;
197
- db_prepare(&q2,
197
+ db_prepare(&q2,
198198
"SELECT content FROM undo"
199199
" WHERE pathname=%Q AND octet_length(content)=%d",
200200
zFN, sz
201201
);
202202
blob_zero(&v1);
@@ -231,10 +231,17 @@
231231
blob_reset(&v1);
232232
blob_reset(&v2);
233233
blob_reset(&out);
234234
db_finalize(&q);
235235
}
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
+}
236243
237244
/*
238245
** COMMAND: merge-info
239246
**
240247
** Usage: %fossil merge-info [OPTIONS]
@@ -242,27 +249,30 @@
242249
** Display information about the most recent merge operation.
243250
**
244251
** Options:
245252
** -a|--all Show all file changes that happened because of
246253
** the merge. Normally only MERGE, CONFLICT, and ERROR
247
-** lines are shown
254
+** lines are shown.
248255
** -c|--context N Show N lines of context around each change,
249256
** with negative N meaning show all content. Only
250257
** 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.
252259
** --tcl FILE Generate (to stdout) a TCL list containing
253260
** information needed to display the changes to
254261
** FILE caused by the most recent merge. FILE must
255262
** be a pathname relative to the root of the check-out.
256263
** --tk Bring up a Tcl/Tk GUI that shows the changes
257264
** 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.
259267
*/
260268
void merge_info_cmd(void){
261269
const char *zCnt;
262270
const char *zTcl;
263271
int bTk;
272
+ int bBrowser;
273
+ int bHtml;
264274
int bDark;
265275
int bAll;
266276
int nContext;
267277
Stmt q;
268278
const char *zWhere;
@@ -269,14 +279,16 @@
269279
int cnt = 0;
270280
271281
db_must_be_within_tree();
272282
zTcl = find_option("tcl", 0, 1);
273283
bTk = find_option("tk", 0, 0)!=0;
284
+ bBrowser = find_option("browser", "b", 0)!=0;
285
+ bHtml = find_option("html", 0, 0)!=0 || bBrowser;
274286
zCnt = find_option("context", "c", 1);
275287
bDark = find_option("dark", 0, 0)!=0;
276288
bAll = find_option("all", "a", 0)!=0;
277
- if( bTk==0 ){
289
+ if( (bTk + bHtml)==0 ){
278290
verify_all_options();
279291
if( g.argc>2 ){
280292
usage("[OPTIONS]");
281293
}
282294
}
@@ -295,12 +307,14 @@
295307
return;
296308
}
297309
if( bTk ){
298310
merge_info_tk(bDark, bAll, nContext);
299311
return;
300
- }
301
- if( zTcl ){
312
+ }else if( bHtml ){
313
+ merge_info_html(bBrowser, bDark, bAll, nContext);
314
+ return;
315
+ }else if( zTcl ){
302316
merge_info_tcl(zTcl, nContext);
303317
return;
304318
}
305319
if( bAll ){
306320
zWhere = "";
307321
--- 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

Keyboard Shortcuts

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