Fossil SCM

Add skeleton for the MergeBuilderHtml, but it doesn't do anything right now except for fail to outright crash. Add an empty TITLE tag to the diff web page output so that a title can be more easily set via JS.

stephan 2024-12-07 05:19 merge-info-html
Commit e76aceba7cab092ce591795da95772355027fb0dae49cd70a6c790a695b8531f
3 files changed +2 +22 -13 +79 -8
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -223,10 +223,11 @@
223223
static const char zWebpageHdr[] =
224224
@ <!DOCTYPE html>
225225
@ <html>
226226
@ <head>
227227
@ <meta charset="UTF-8">
228
+@ <title></title>
228229
@ <style>
229230
@ body {
230231
@ background-color: white;
231232
@ }
232233
@ h1 {
@@ -352,10 +353,11 @@
352353
static const char zWebpageHdrDark[] =
353354
@ <!DOCTYPE html>
354355
@ <html>
355356
@ <head>
356357
@ <meta charset="UTF-8">
358
+@ <title></title>
357359
@ <style>
358360
@ body {
359361
@ background-color: #353535;
360362
@ color: #ffffff;
361363
@ }
362364
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -223,10 +223,11 @@
223 static const char zWebpageHdr[] =
224 @ <!DOCTYPE html>
225 @ <html>
226 @ <head>
227 @ <meta charset="UTF-8">
 
228 @ <style>
229 @ body {
230 @ background-color: white;
231 @ }
232 @ h1 {
@@ -352,10 +353,11 @@
352 static const char zWebpageHdrDark[] =
353 @ <!DOCTYPE html>
354 @ <html>
355 @ <head>
356 @ <meta charset="UTF-8">
 
357 @ <style>
358 @ body {
359 @ background-color: #353535;
360 @ color: #ffffff;
361 @ }
362
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -223,10 +223,11 @@
223 static const char zWebpageHdr[] =
224 @ <!DOCTYPE html>
225 @ <html>
226 @ <head>
227 @ <meta charset="UTF-8">
228 @ <title></title>
229 @ <style>
230 @ body {
231 @ background-color: white;
232 @ }
233 @ h1 {
@@ -352,10 +353,11 @@
353 static const char zWebpageHdrDark[] =
354 @ <!DOCTYPE html>
355 @ <html>
356 @ <head>
357 @ <meta charset="UTF-8">
358 @ <title></title>
359 @ <style>
360 @ body {
361 @ background-color: #353535;
362 @ color: #ffffff;
363 @ }
364
+22 -13
--- src/merge.c
+++ src/merge.c
@@ -270,35 +270,43 @@
270270
"mrgBaseLn mrgBase mrgBaseSep "
271271
"mrgLocalLn mrgLocal mrgLocalSep "
272272
"mrgMILn mrgMI mrgMISep "
273273
"mrgResLn mrgRes\";\n"
274274
"}\n", -1);
275
-#define DA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1)
276
- DA(mrgBaseLn);
277
- DA(mrgBase);
278
- DA(mrgBaseSep);
279
- DA(mrgLocalLn);
280
- DA(mrgLocal);
281
- DA(mrgLocalSep);
282
- DA(mrgMILn);
283
- DA(mrgMI);
284
- DA(mrgMISep);
285
- DA(mrgResLn);
286
- DA(mrgRes);
287
-#undef DA
275
+#define GA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1)
276
+ GA(mrgBaseLn);
277
+ GA(mrgBase);
278
+ GA(mrgBaseSep);
279
+ GA(mrgLocalLn);
280
+ GA(mrgLocal);
281
+ GA(mrgLocalSep);
282
+ GA(mrgMILn);
283
+ GA(mrgMI);
284
+ GA(mrgMISep);
285
+ GA(mrgResLn);
286
+ GA(mrgRes);
287
+#undef GA
288288
blob_append(p, "</style>\n", -1);
289289
}
290
+
291
+/*static void merge_info_html_one(MergeBuilderHtml *pB, Blob *pOut,
292
+ const char *zOp, const char *zFile){
293
+}*/
290294
291295
/*
292296
** The HTML counterpart of merge_info_tk().
293297
*/
294298
static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */
295299
int bDark, /* use dark mode */
296300
int bAll, /* All changes, not just merged content */
297301
int nContext /* Diff context lines */){
298302
Blob out = empty_blob;
303
+ MergeBuilderHtml mbh;
304
+ MergeBuilder * mb = &mbh.base;
299305
306
+ mergebuilder_init_html(&mbh);
307
+ mb->nContext = nContext;
300308
blob_append(&out, diff_webpage_header(bDark), -1);
301309
merge_info_html_css(&out);
302310
303311
if( g.argc==2 ){
304312
/* No files named on the command-line. Use every file mentioned
@@ -352,10 +360,11 @@
352360
353361
blob_append(&out, diff_webpage_footer(), -1);
354362
blob_append_char(&out, '\n');
355363
blob_write_to_file(&out, "-");
356364
blob_reset(&out);
365
+ mb->xDestroy(mb);
357366
}
358367
359368
/*
360369
** COMMAND: merge-info
361370
**
362371
--- src/merge.c
+++ src/merge.c
@@ -270,35 +270,43 @@
270 "mrgBaseLn mrgBase mrgBaseSep "
271 "mrgLocalLn mrgLocal mrgLocalSep "
272 "mrgMILn mrgMI mrgMISep "
273 "mrgResLn mrgRes\";\n"
274 "}\n", -1);
275 #define DA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1)
276 DA(mrgBaseLn);
277 DA(mrgBase);
278 DA(mrgBaseSep);
279 DA(mrgLocalLn);
280 DA(mrgLocal);
281 DA(mrgLocalSep);
282 DA(mrgMILn);
283 DA(mrgMI);
284 DA(mrgMISep);
285 DA(mrgResLn);
286 DA(mrgRes);
287 #undef DA
288 blob_append(p, "</style>\n", -1);
289 }
 
 
 
 
290
291 /*
292 ** The HTML counterpart of merge_info_tk().
293 */
294 static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */
295 int bDark, /* use dark mode */
296 int bAll, /* All changes, not just merged content */
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
@@ -352,10 +360,11 @@
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 }
358
359 /*
360 ** COMMAND: merge-info
361 **
362
--- src/merge.c
+++ src/merge.c
@@ -270,35 +270,43 @@
270 "mrgBaseLn mrgBase mrgBaseSep "
271 "mrgLocalLn mrgLocal mrgLocalSep "
272 "mrgMILn mrgMI mrgMISep "
273 "mrgResLn mrgRes\";\n"
274 "}\n", -1);
275 #define GA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1)
276 GA(mrgBaseLn);
277 GA(mrgBase);
278 GA(mrgBaseSep);
279 GA(mrgLocalLn);
280 GA(mrgLocal);
281 GA(mrgLocalSep);
282 GA(mrgMILn);
283 GA(mrgMI);
284 GA(mrgMISep);
285 GA(mrgResLn);
286 GA(mrgRes);
287 #undef GA
288 blob_append(p, "</style>\n", -1);
289 }
290
291 /*static void merge_info_html_one(MergeBuilderHtml *pB, Blob *pOut,
292 const char *zOp, const char *zFile){
293 }*/
294
295 /*
296 ** The HTML counterpart of merge_info_tk().
297 */
298 static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */
299 int bDark, /* use dark mode */
300 int bAll, /* All changes, not just merged content */
301 int nContext /* Diff context lines */){
302 Blob out = empty_blob;
303 MergeBuilderHtml mbh;
304 MergeBuilder * mb = &mbh.base;
305
306 mergebuilder_init_html(&mbh);
307 mb->nContext = nContext;
308 blob_append(&out, diff_webpage_header(bDark), -1);
309 merge_info_html_css(&out);
310
311 if( g.argc==2 ){
312 /* No files named on the command-line. Use every file mentioned
@@ -352,10 +360,11 @@
360
361 blob_append(&out, diff_webpage_footer(), -1);
362 blob_append_char(&out, '\n');
363 blob_write_to_file(&out, "-");
364 blob_reset(&out);
365 mb->xDestroy(mb);
366 }
367
368 /*
369 ** COMMAND: merge-info
370 **
371
+79 -8
--- src/merge3.c
+++ src/merge3.c
@@ -166,28 +166,41 @@
166166
unsigned int lnV2; /* Lines read from v2 */
167167
unsigned int lnOut; /* Lines written to out */
168168
unsigned int nConflict; /* Number of conflicts seen */
169169
u64 diffFlags; /* Flags for difference engine */
170170
};
171
+
172
+struct MergeBuilderHtml {
173
+ struct MergeBuilder base;
174
+ /*
175
+ ** Columns for each of the entries in this summary of the HTML
176
+ ** layout:
177
+ **
178
+ ** # baseline C # local C # merged-in C # merge-result
179
+ ** 0-1--------2-3-4-----5-6-7---------8-9-10
180
+ */
181
+ Blob aCol[11];
182
+};
171183
#endif /* INTERFACE */
172184
173185
174186
/************************* Generic MergeBuilder ******************************/
175187
/* These are generic methods for MergeBuilder. They just output debugging
176188
** information. But some of them are useful as base methods for other useful
177189
** implementations of MergeBuilder.
178190
*/
179191
180
-/* xStart() and xEnd() are called to generate header and fotter information
181
-** in the output. This is a no-op in the generic implementation.
192
+/* xStart() and xEnd() are called to generate header and footer
193
+** information in the output. This is a no-op in the generic
194
+** implementation.
182195
*/
183196
static void dbgStartEnd(MergeBuilder *p){ (void)p; }
184197
185198
/* The next N lines of PIVOT are unchanged in both V1 and V2
186199
*/
187200
static void dbgSame(MergeBuilder *p, unsigned int N){
188
- blob_appendf(p->pOut,
201
+ blob_appendf(p->pOut,
189202
"COPY %u from BASELINE(%u..%u) or V1(%u..%u) or V2(%u..%u)\n",
190203
N, p->lnPivot+1, p->lnPivot+N, p->lnV1+1, p->lnV1+N,
191204
p->lnV2+1, p->lnV2+N);
192205
p->lnPivot += N;
193206
p->lnV1 += N;
@@ -233,11 +246,11 @@
233246
MergeBuilder *p,
234247
unsigned int nPivot,
235248
unsigned int nV1,
236249
unsigned int nV2
237250
){
238
- blob_appendf(p->pOut,
251
+ blob_appendf(p->pOut,
239252
"CONFLICT %u,%u,%u BASELINE(%u..%u) versus V1(%u..%u) versus V2(%u..%u)\n",
240253
nPivot, nV1, nV2,
241254
p->lnPivot+1, p->lnPivot+nPivot,
242255
p->lnV1+1, p->lnV1+nV1,
243256
p->lnV2+1, p->lnV2+nV2);
@@ -323,11 +336,12 @@
323336
** This routine attempts to resolve the conflict by looking at
324337
** elements of the conflict region that are finer grain than complete
325338
** lines of text.
326339
**
327340
** The result is written into Blob pOut. pOut is initialized by this
328
-** routine.
341
+** routine. Returns the result of passing the merge state to
342
+** merge_three_blobs().
329343
*/
330344
int merge_try_to_resolve_conflict(
331345
MergeBuilder *pMB, /* MergeBuilder that encounter conflict */
332346
unsigned int nPivot, /* Lines of conflict in the pivot */
333347
unsigned int nV1, /* Lines of conflict in V1 */
@@ -630,11 +644,11 @@
630644
){
631645
int mx = nPivot;
632646
int i;
633647
int nRes;
634648
Blob res;
635
-
649
+
636650
merge_try_to_resolve_conflict(p, nPivot, nV1, nV2, &res);
637651
nRes = blob_linecount(&res);
638652
if( nV1>mx ) mx = nV1;
639653
if( nV2>mx ) mx = nV2;
640654
if( nRes>mx ) mx = nRes;
@@ -682,10 +696,67 @@
682696
p->xChngV1 = tclChngV1;
683697
p->xChngV2 = tclChngV2;
684698
p->xChngBoth = tclChngBoth;
685699
p->xConflict = tclConflict;
686700
}
701
+
702
+/* MergeBuilderHtml::xStart() */
703
+static void htmlStart(MergeBuilder *p){
704
+ MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
705
+ unsigned int i;
706
+
707
+ /* TODO: open HTML table */
708
+ for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
709
+ blob_zero(&pH->aCol[i]);
710
+ }
711
+}
712
+/* MergeBuilderHtml::xEnd() */
713
+static void htmlEnd(MergeBuilder *p){
714
+ MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
715
+ unsigned int i;
716
+
717
+ /* TODO: flush pH->aCol to p->pOut and close HTML table */
718
+ for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
719
+ blob_reset(&pH->aCol[i]);
720
+ }
721
+}
722
+/* MergeBuilderHtml::xSame() */
723
+static void htmlSame(MergeBuilder *p, unsigned int N){
724
+}
725
+/* MergeBuilderHtml::xChngV1() */
726
+static void htmlChngV1(MergeBuilder *p, unsigned int nPivot, unsigned int nV1){
727
+}
728
+/* MergeBuilderHtml::xChngV2() */
729
+static void htmlChngV2(MergeBuilder *p, unsigned int nPivot, unsigned int nV2){
730
+}
731
+/* MergeBuilderHtml::xChngBoth() */
732
+static void htmlChngBoth(MergeBuilder *p, unsigned int nPivot, unsigned int nV){
733
+}
734
+/* MergeBuilderHtml::xConflict() */
735
+static void htmlConflict(
736
+ MergeBuilder *p,
737
+ unsigned int nPivot,
738
+ unsigned int nV1,
739
+ unsigned int nV2
740
+){
741
+}
742
+void mergebuilder_init_html(MergeBuilderHtml *pH){
743
+ MergeBuilder *p = &pH->base;
744
+ unsigned int i;
745
+ mergebuilder_init(p);
746
+ p->xStart = htmlStart;
747
+ p->xEnd = htmlEnd;
748
+ p->xSame = htmlSame;
749
+ p->xChngV1 = htmlChngV1;
750
+ p->xChngV2 = htmlChngV2;
751
+ p->xChngBoth = htmlChngBoth;
752
+ p->xConflict = htmlConflict;
753
+ for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
754
+ pH->aCol[i] = empty_blob;
755
+ }
756
+}
757
+
687758
/*****************************************************************************/
688759
689760
/*
690761
** The aC[] array contains triples of integers. Within each triple, the
691762
** elements are:
@@ -744,11 +815,11 @@
744815
** to pV2.
745816
**
746817
** The return is 0 upon complete success. If any input file is binary,
747818
** -1 is returned and pOut is unmodified. If there are merge
748819
** conflicts, the merge proceeds as best as it can and the number
749
-** of conflicts is returns
820
+** of conflicts is returned.
750821
*/
751822
int merge_three_blobs(MergeBuilder *p){
752823
int *aC1; /* Changes from pPivot to pV1 */
753824
int *aC2; /* Changes from pPivot to pV2 */
754825
int i1, i2; /* Index into aC1[] and aC2[] */
@@ -848,11 +919,11 @@
848919
}
849920
i1 = skip_conflict(aC1, i1, sz, &nV1);
850921
i2 = skip_conflict(aC2, i2, sz, &nV2);
851922
p->xConflict(p, sz, nV1, nV2);
852923
}
853
-
924
+
854925
/* If we are finished with an edit triple, advance to the next
855926
** triple.
856927
*/
857928
if( i1<limit1 && aC1[i1]==0 && aC1[i1+1]==0 && aC1[i1+2]==0 ) i1+=3;
858929
if( i2<limit2 && aC2[i2]==0 && aC2[i2+1]==0 && aC2[i2+2]==0 ) i2+=3;
859930
--- src/merge3.c
+++ src/merge3.c
@@ -166,28 +166,41 @@
166 unsigned int lnV2; /* Lines read from v2 */
167 unsigned int lnOut; /* Lines written to out */
168 unsigned int nConflict; /* Number of conflicts seen */
169 u64 diffFlags; /* Flags for difference engine */
170 };
 
 
 
 
 
 
 
 
 
 
 
 
171 #endif /* INTERFACE */
172
173
174 /************************* Generic MergeBuilder ******************************/
175 /* These are generic methods for MergeBuilder. They just output debugging
176 ** information. But some of them are useful as base methods for other useful
177 ** implementations of MergeBuilder.
178 */
179
180 /* xStart() and xEnd() are called to generate header and fotter information
181 ** in the output. This is a no-op in the generic implementation.
 
182 */
183 static void dbgStartEnd(MergeBuilder *p){ (void)p; }
184
185 /* The next N lines of PIVOT are unchanged in both V1 and V2
186 */
187 static void dbgSame(MergeBuilder *p, unsigned int N){
188 blob_appendf(p->pOut,
189 "COPY %u from BASELINE(%u..%u) or V1(%u..%u) or V2(%u..%u)\n",
190 N, p->lnPivot+1, p->lnPivot+N, p->lnV1+1, p->lnV1+N,
191 p->lnV2+1, p->lnV2+N);
192 p->lnPivot += N;
193 p->lnV1 += N;
@@ -233,11 +246,11 @@
233 MergeBuilder *p,
234 unsigned int nPivot,
235 unsigned int nV1,
236 unsigned int nV2
237 ){
238 blob_appendf(p->pOut,
239 "CONFLICT %u,%u,%u BASELINE(%u..%u) versus V1(%u..%u) versus V2(%u..%u)\n",
240 nPivot, nV1, nV2,
241 p->lnPivot+1, p->lnPivot+nPivot,
242 p->lnV1+1, p->lnV1+nV1,
243 p->lnV2+1, p->lnV2+nV2);
@@ -323,11 +336,12 @@
323 ** This routine attempts to resolve the conflict by looking at
324 ** elements of the conflict region that are finer grain than complete
325 ** lines of text.
326 **
327 ** The result is written into Blob pOut. pOut is initialized by this
328 ** routine.
 
329 */
330 int merge_try_to_resolve_conflict(
331 MergeBuilder *pMB, /* MergeBuilder that encounter conflict */
332 unsigned int nPivot, /* Lines of conflict in the pivot */
333 unsigned int nV1, /* Lines of conflict in V1 */
@@ -630,11 +644,11 @@
630 ){
631 int mx = nPivot;
632 int i;
633 int nRes;
634 Blob res;
635
636 merge_try_to_resolve_conflict(p, nPivot, nV1, nV2, &res);
637 nRes = blob_linecount(&res);
638 if( nV1>mx ) mx = nV1;
639 if( nV2>mx ) mx = nV2;
640 if( nRes>mx ) mx = nRes;
@@ -682,10 +696,67 @@
682 p->xChngV1 = tclChngV1;
683 p->xChngV2 = tclChngV2;
684 p->xChngBoth = tclChngBoth;
685 p->xConflict = tclConflict;
686 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687 /*****************************************************************************/
688
689 /*
690 ** The aC[] array contains triples of integers. Within each triple, the
691 ** elements are:
@@ -744,11 +815,11 @@
744 ** to pV2.
745 **
746 ** The return is 0 upon complete success. If any input file is binary,
747 ** -1 is returned and pOut is unmodified. If there are merge
748 ** conflicts, the merge proceeds as best as it can and the number
749 ** of conflicts is returns
750 */
751 int merge_three_blobs(MergeBuilder *p){
752 int *aC1; /* Changes from pPivot to pV1 */
753 int *aC2; /* Changes from pPivot to pV2 */
754 int i1, i2; /* Index into aC1[] and aC2[] */
@@ -848,11 +919,11 @@
848 }
849 i1 = skip_conflict(aC1, i1, sz, &nV1);
850 i2 = skip_conflict(aC2, i2, sz, &nV2);
851 p->xConflict(p, sz, nV1, nV2);
852 }
853
854 /* If we are finished with an edit triple, advance to the next
855 ** triple.
856 */
857 if( i1<limit1 && aC1[i1]==0 && aC1[i1+1]==0 && aC1[i1+2]==0 ) i1+=3;
858 if( i2<limit2 && aC2[i2]==0 && aC2[i2+1]==0 && aC2[i2+2]==0 ) i2+=3;
859
--- src/merge3.c
+++ src/merge3.c
@@ -166,28 +166,41 @@
166 unsigned int lnV2; /* Lines read from v2 */
167 unsigned int lnOut; /* Lines written to out */
168 unsigned int nConflict; /* Number of conflicts seen */
169 u64 diffFlags; /* Flags for difference engine */
170 };
171
172 struct MergeBuilderHtml {
173 struct MergeBuilder base;
174 /*
175 ** Columns for each of the entries in this summary of the HTML
176 ** layout:
177 **
178 ** # baseline C # local C # merged-in C # merge-result
179 ** 0-1--------2-3-4-----5-6-7---------8-9-10
180 */
181 Blob aCol[11];
182 };
183 #endif /* INTERFACE */
184
185
186 /************************* Generic MergeBuilder ******************************/
187 /* These are generic methods for MergeBuilder. They just output debugging
188 ** information. But some of them are useful as base methods for other useful
189 ** implementations of MergeBuilder.
190 */
191
192 /* xStart() and xEnd() are called to generate header and footer
193 ** information in the output. This is a no-op in the generic
194 ** implementation.
195 */
196 static void dbgStartEnd(MergeBuilder *p){ (void)p; }
197
198 /* The next N lines of PIVOT are unchanged in both V1 and V2
199 */
200 static void dbgSame(MergeBuilder *p, unsigned int N){
201 blob_appendf(p->pOut,
202 "COPY %u from BASELINE(%u..%u) or V1(%u..%u) or V2(%u..%u)\n",
203 N, p->lnPivot+1, p->lnPivot+N, p->lnV1+1, p->lnV1+N,
204 p->lnV2+1, p->lnV2+N);
205 p->lnPivot += N;
206 p->lnV1 += N;
@@ -233,11 +246,11 @@
246 MergeBuilder *p,
247 unsigned int nPivot,
248 unsigned int nV1,
249 unsigned int nV2
250 ){
251 blob_appendf(p->pOut,
252 "CONFLICT %u,%u,%u BASELINE(%u..%u) versus V1(%u..%u) versus V2(%u..%u)\n",
253 nPivot, nV1, nV2,
254 p->lnPivot+1, p->lnPivot+nPivot,
255 p->lnV1+1, p->lnV1+nV1,
256 p->lnV2+1, p->lnV2+nV2);
@@ -323,11 +336,12 @@
336 ** This routine attempts to resolve the conflict by looking at
337 ** elements of the conflict region that are finer grain than complete
338 ** lines of text.
339 **
340 ** The result is written into Blob pOut. pOut is initialized by this
341 ** routine. Returns the result of passing the merge state to
342 ** merge_three_blobs().
343 */
344 int merge_try_to_resolve_conflict(
345 MergeBuilder *pMB, /* MergeBuilder that encounter conflict */
346 unsigned int nPivot, /* Lines of conflict in the pivot */
347 unsigned int nV1, /* Lines of conflict in V1 */
@@ -630,11 +644,11 @@
644 ){
645 int mx = nPivot;
646 int i;
647 int nRes;
648 Blob res;
649
650 merge_try_to_resolve_conflict(p, nPivot, nV1, nV2, &res);
651 nRes = blob_linecount(&res);
652 if( nV1>mx ) mx = nV1;
653 if( nV2>mx ) mx = nV2;
654 if( nRes>mx ) mx = nRes;
@@ -682,10 +696,67 @@
696 p->xChngV1 = tclChngV1;
697 p->xChngV2 = tclChngV2;
698 p->xChngBoth = tclChngBoth;
699 p->xConflict = tclConflict;
700 }
701
702 /* MergeBuilderHtml::xStart() */
703 static void htmlStart(MergeBuilder *p){
704 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
705 unsigned int i;
706
707 /* TODO: open HTML table */
708 for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
709 blob_zero(&pH->aCol[i]);
710 }
711 }
712 /* MergeBuilderHtml::xEnd() */
713 static void htmlEnd(MergeBuilder *p){
714 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
715 unsigned int i;
716
717 /* TODO: flush pH->aCol to p->pOut and close HTML table */
718 for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
719 blob_reset(&pH->aCol[i]);
720 }
721 }
722 /* MergeBuilderHtml::xSame() */
723 static void htmlSame(MergeBuilder *p, unsigned int N){
724 }
725 /* MergeBuilderHtml::xChngV1() */
726 static void htmlChngV1(MergeBuilder *p, unsigned int nPivot, unsigned int nV1){
727 }
728 /* MergeBuilderHtml::xChngV2() */
729 static void htmlChngV2(MergeBuilder *p, unsigned int nPivot, unsigned int nV2){
730 }
731 /* MergeBuilderHtml::xChngBoth() */
732 static void htmlChngBoth(MergeBuilder *p, unsigned int nPivot, unsigned int nV){
733 }
734 /* MergeBuilderHtml::xConflict() */
735 static void htmlConflict(
736 MergeBuilder *p,
737 unsigned int nPivot,
738 unsigned int nV1,
739 unsigned int nV2
740 ){
741 }
742 void mergebuilder_init_html(MergeBuilderHtml *pH){
743 MergeBuilder *p = &pH->base;
744 unsigned int i;
745 mergebuilder_init(p);
746 p->xStart = htmlStart;
747 p->xEnd = htmlEnd;
748 p->xSame = htmlSame;
749 p->xChngV1 = htmlChngV1;
750 p->xChngV2 = htmlChngV2;
751 p->xChngBoth = htmlChngBoth;
752 p->xConflict = htmlConflict;
753 for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
754 pH->aCol[i] = empty_blob;
755 }
756 }
757
758 /*****************************************************************************/
759
760 /*
761 ** The aC[] array contains triples of integers. Within each triple, the
762 ** elements are:
@@ -744,11 +815,11 @@
815 ** to pV2.
816 **
817 ** The return is 0 upon complete success. If any input file is binary,
818 ** -1 is returned and pOut is unmodified. If there are merge
819 ** conflicts, the merge proceeds as best as it can and the number
820 ** of conflicts is returned.
821 */
822 int merge_three_blobs(MergeBuilder *p){
823 int *aC1; /* Changes from pPivot to pV1 */
824 int *aC2; /* Changes from pPivot to pV2 */
825 int i1, i2; /* Index into aC1[] and aC2[] */
@@ -848,11 +919,11 @@
919 }
920 i1 = skip_conflict(aC1, i1, sz, &nV1);
921 i2 = skip_conflict(aC2, i2, sz, &nV2);
922 p->xConflict(p, sz, nV1, nV2);
923 }
924
925 /* If we are finished with an edit triple, advance to the next
926 ** triple.
927 */
928 if( i1<limit1 && aC1[i1]==0 && aC1[i1+1]==0 && aC1[i1+2]==0 ) i1+=3;
929 if( i2<limit2 && aC2[i2]==0 && aC2[i2+1]==0 && aC2[i2+2]==0 ) i2+=3;
930

Keyboard Shortcuts

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