Fossil SCM

Move filename info into the corresponding merge-info table. Start adding infrastructure for emitting HTML-mode output to the content columns.

stephan 2024-12-09 08:17 merge-info-html
Commit e3a3f0a5f224492ec0c4b1379e31e262760e6f139f694335faf289148e57cf91
2 files changed +3 +34 -19
--- src/merge.c
+++ src/merge.c
@@ -255,10 +255,13 @@
255255
** we should probably apply change status markers like the
256256
** diff view does.
257257
*/
258258
static void merge_info_html_css(Blob *p){
259259
blob_append(p, "<style>\n", -1);
260
+ blob_append(p, "table.diff {\n"
261
+ "margin-bottom: 1em;"
262
+ "}\n", -1);
260263
blob_append(p, "tr.diffchunk {\n"
261264
"display: grid; gap: 0px 0px;\n"
262265
"grid-template-rows: 1fr;\n"
263266
"grid-template-columns: "
264267
"auto 1fr auto " /* # baseline sep */
265268
--- src/merge.c
+++ src/merge.c
@@ -255,10 +255,13 @@
255 ** we should probably apply change status markers like the
256 ** diff view does.
257 */
258 static void merge_info_html_css(Blob *p){
259 blob_append(p, "<style>\n", -1);
 
 
 
260 blob_append(p, "tr.diffchunk {\n"
261 "display: grid; gap: 0px 0px;\n"
262 "grid-template-rows: 1fr;\n"
263 "grid-template-columns: "
264 "auto 1fr auto " /* # baseline sep */
265
--- src/merge.c
+++ src/merge.c
@@ -255,10 +255,13 @@
255 ** we should probably apply change status markers like the
256 ** diff view does.
257 */
258 static void merge_info_html_css(Blob *p){
259 blob_append(p, "<style>\n", -1);
260 blob_append(p, "table.diff {\n"
261 "margin-bottom: 1em;"
262 "}\n", -1);
263 blob_append(p, "tr.diffchunk {\n"
264 "display: grid; gap: 0px 0px;\n"
265 "grid-template-rows: 1fr;\n"
266 "grid-template-columns: "
267 "auto 1fr auto " /* # baseline sep */
268
+34 -19
--- src/merge3.c
+++ src/merge3.c
@@ -712,44 +712,59 @@
712712
p->xChngV1 = tclChngV1;
713713
p->xChngV2 = tclChngV2;
714714
p->xChngBoth = tclChngBoth;
715715
p->xConflict = tclConflict;
716716
}
717
+
718
+/*
719
+** Works like blob_copy_lines() except that if pTo is not NULL, the
720
+** copied content is HTML-escaped.
721
+*/
722
+/*static*/ void htmlCopyLines(Blob *pTo, Blob *pFrom, int N){
723
+ const unsigned int iStart = pFrom->iCursor;
724
+ blob_copy_lines(0, pFrom, N);
725
+ if( pTo ){
726
+ assert( iStart <= pFrom->iCursor );
727
+ htmlize_to_blob(pTo, blob_str(pFrom) + iStart, (int)(pFrom->iCursor - iStart));
728
+ }
729
+}
717730
718731
/* MergeBuilderHtml::xStart() */
719732
static void htmlStart(MergeBuilder *p){
720733
MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
721734
unsigned int i;
722735
723736
for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
724737
blob_zero(&pH->aCol[i]);
725738
}
726
- /* TODO: open HTML table in p->pOut */
727
- blob_appendf(p->pOut, "<h1>%h &rarr; (%h, %h) &rarr; %h</h1>",
728
- p->zPivot, p->zV1, p->zV2, p->zOut);
729
- /* Reminder; MergeBuilder does not currently contain enough state to
739
+ /* Reminder: MergeBuilder does not currently contain enough state to
730740
** let us include version info in this diff. We have the raw content
731741
** of p->pPivot and p->pV2, but p->pV1 may be locally edited. We
732742
** can't readily know whether we need to use SHA1 or SHA3 to find it
733743
** in the blob table. */
734744
blob_append(p->pOut,
735
- "<table class='diff'><tbody>"
736
- "<tr class='diffchunk'>\n", -1);
737
-#define DCOL(KEY,KLASS,DUMMY) \
738
- blob_appendf(&pH->aCol[KEY], "<td class='" KLASS "'><pre>%h", DUMMY)
739
- DCOL(MBH_COL_BASELINE_LN, "mrgBaseLn diffln", "###");
740
- DCOL(MBH_COL_BASELINE, "mrgBase", "merge base");
741
- DCOL(MBH_COL_BASELINE_SEP, "mrgBaseSep diffsep", " ");
742
- DCOL(MBH_COL_LOCAL_LN, "mrgLocalLn diffln", "###");
743
- DCOL(MBH_COL_LOCAL, "mrgLocal", "local");
744
- DCOL(MBH_COL_LOCAL_SEP, "mrgLocalSep diffsep", " ");
745
- DCOL(MBH_COL_MERGEDIN_LN, "mrgMILn diffln", "###");
746
- DCOL(MBH_COL_MERGEDIN, "mrgMI", "merged-in");
747
- DCOL(MBH_COL_MERGEDIN_SEP, "mrgMISep diffsep", " ");
748
- DCOL(MBH_COL_RESULT_LN, "mrgResLn diffln", "###");
749
- DCOL(MBH_COL_RESULT, "mrgRes", "merge result");
745
+ "<table class='diff'>", -1);
746
+ blob_append(p->pOut, "<thead><tr class='diffchunk'>", -1);
747
+#define DCOL(KEY,KLASS,DUMMY,FILENAME) \
748
+ blob_appendf(&pH->aCol[KEY], "<td class='" KLASS "'><pre>%h", DUMMY); \
749
+ blob_append(p->pOut, "<td class='" KLASS "'>", -1 ); \
750
+ if( FILENAME ) blob_appendf(p->pOut, "%h", FILENAME); \
751
+ blob_append(p->pOut, "</td>", -1)
752
+ DCOL(MBH_COL_BASELINE_LN, "mrgBaseLn diffln", "###", 0);
753
+ DCOL(MBH_COL_BASELINE, "mrgBase", "", p->zPivot);
754
+ DCOL(MBH_COL_BASELINE_SEP, "mrgBaseSep diffsep", " ", 0);
755
+ DCOL(MBH_COL_LOCAL_LN, "mrgLocalLn diffln", "###", 0);
756
+ DCOL(MBH_COL_LOCAL, "mrgLocal", "", p->zV1);
757
+ DCOL(MBH_COL_LOCAL_SEP, "mrgLocalSep diffsep", " ", 0);
758
+ DCOL(MBH_COL_MERGEDIN_LN, "mrgMILn diffln", "###", 0);
759
+ DCOL(MBH_COL_MERGEDIN, "mrgMI", "", p->zV2);
760
+ DCOL(MBH_COL_MERGEDIN_SEP, "mrgMISep diffsep", " ", 0);
761
+ DCOL(MBH_COL_RESULT_LN, "mrgResLn diffln", "###", 0);
762
+ DCOL(MBH_COL_RESULT, "mrgRes", "", p->zOut);
750763
#undef DCOL
764
+ blob_append(p->pOut, "</tr></thead>\n"
765
+ "<tbody><tr class='diffchunk'>\n", -1);
751766
}
752767
753768
/* MergeBuilderHtml::xEnd() */
754769
static void htmlEnd(MergeBuilder *p){
755770
MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
756771
--- src/merge3.c
+++ src/merge3.c
@@ -712,44 +712,59 @@
712 p->xChngV1 = tclChngV1;
713 p->xChngV2 = tclChngV2;
714 p->xChngBoth = tclChngBoth;
715 p->xConflict = tclConflict;
716 }
 
 
 
 
 
 
 
 
 
 
 
 
 
717
718 /* MergeBuilderHtml::xStart() */
719 static void htmlStart(MergeBuilder *p){
720 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
721 unsigned int i;
722
723 for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
724 blob_zero(&pH->aCol[i]);
725 }
726 /* TODO: open HTML table in p->pOut */
727 blob_appendf(p->pOut, "<h1>%h &rarr; (%h, %h) &rarr; %h</h1>",
728 p->zPivot, p->zV1, p->zV2, p->zOut);
729 /* Reminder; MergeBuilder does not currently contain enough state to
730 ** let us include version info in this diff. We have the raw content
731 ** of p->pPivot and p->pV2, but p->pV1 may be locally edited. We
732 ** can't readily know whether we need to use SHA1 or SHA3 to find it
733 ** in the blob table. */
734 blob_append(p->pOut,
735 "<table class='diff'><tbody>"
736 "<tr class='diffchunk'>\n", -1);
737 #define DCOL(KEY,KLASS,DUMMY) \
738 blob_appendf(&pH->aCol[KEY], "<td class='" KLASS "'><pre>%h", DUMMY)
739 DCOL(MBH_COL_BASELINE_LN, "mrgBaseLn diffln", "###");
740 DCOL(MBH_COL_BASELINE, "mrgBase", "merge base");
741 DCOL(MBH_COL_BASELINE_SEP, "mrgBaseSep diffsep", " ");
742 DCOL(MBH_COL_LOCAL_LN, "mrgLocalLn diffln", "###");
743 DCOL(MBH_COL_LOCAL, "mrgLocal", "local");
744 DCOL(MBH_COL_LOCAL_SEP, "mrgLocalSep diffsep", " ");
745 DCOL(MBH_COL_MERGEDIN_LN, "mrgMILn diffln", "###");
746 DCOL(MBH_COL_MERGEDIN, "mrgMI", "merged-in");
747 DCOL(MBH_COL_MERGEDIN_SEP, "mrgMISep diffsep", " ");
748 DCOL(MBH_COL_RESULT_LN, "mrgResLn diffln", "###");
749 DCOL(MBH_COL_RESULT, "mrgRes", "merge result");
 
 
 
750 #undef DCOL
 
 
751 }
752
753 /* MergeBuilderHtml::xEnd() */
754 static void htmlEnd(MergeBuilder *p){
755 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
756
--- src/merge3.c
+++ src/merge3.c
@@ -712,44 +712,59 @@
712 p->xChngV1 = tclChngV1;
713 p->xChngV2 = tclChngV2;
714 p->xChngBoth = tclChngBoth;
715 p->xConflict = tclConflict;
716 }
717
718 /*
719 ** Works like blob_copy_lines() except that if pTo is not NULL, the
720 ** copied content is HTML-escaped.
721 */
722 /*static*/ void htmlCopyLines(Blob *pTo, Blob *pFrom, int N){
723 const unsigned int iStart = pFrom->iCursor;
724 blob_copy_lines(0, pFrom, N);
725 if( pTo ){
726 assert( iStart <= pFrom->iCursor );
727 htmlize_to_blob(pTo, blob_str(pFrom) + iStart, (int)(pFrom->iCursor - iStart));
728 }
729 }
730
731 /* MergeBuilderHtml::xStart() */
732 static void htmlStart(MergeBuilder *p){
733 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
734 unsigned int i;
735
736 for(i = 0; i < sizeof(pH->aCol)/sizeof(Blob); ++i){
737 blob_zero(&pH->aCol[i]);
738 }
739 /* Reminder: MergeBuilder does not currently contain enough state to
 
 
 
740 ** let us include version info in this diff. We have the raw content
741 ** of p->pPivot and p->pV2, but p->pV1 may be locally edited. We
742 ** can't readily know whether we need to use SHA1 or SHA3 to find it
743 ** in the blob table. */
744 blob_append(p->pOut,
745 "<table class='diff'>", -1);
746 blob_append(p->pOut, "<thead><tr class='diffchunk'>", -1);
747 #define DCOL(KEY,KLASS,DUMMY,FILENAME) \
748 blob_appendf(&pH->aCol[KEY], "<td class='" KLASS "'><pre>%h", DUMMY); \
749 blob_append(p->pOut, "<td class='" KLASS "'>", -1 ); \
750 if( FILENAME ) blob_appendf(p->pOut, "%h", FILENAME); \
751 blob_append(p->pOut, "</td>", -1)
752 DCOL(MBH_COL_BASELINE_LN, "mrgBaseLn diffln", "###", 0);
753 DCOL(MBH_COL_BASELINE, "mrgBase", "", p->zPivot);
754 DCOL(MBH_COL_BASELINE_SEP, "mrgBaseSep diffsep", " ", 0);
755 DCOL(MBH_COL_LOCAL_LN, "mrgLocalLn diffln", "###", 0);
756 DCOL(MBH_COL_LOCAL, "mrgLocal", "", p->zV1);
757 DCOL(MBH_COL_LOCAL_SEP, "mrgLocalSep diffsep", " ", 0);
758 DCOL(MBH_COL_MERGEDIN_LN, "mrgMILn diffln", "###", 0);
759 DCOL(MBH_COL_MERGEDIN, "mrgMI", "", p->zV2);
760 DCOL(MBH_COL_MERGEDIN_SEP, "mrgMISep diffsep", " ", 0);
761 DCOL(MBH_COL_RESULT_LN, "mrgResLn diffln", "###", 0);
762 DCOL(MBH_COL_RESULT, "mrgRes", "", p->zOut);
763 #undef DCOL
764 blob_append(p->pOut, "</tr></thead>\n"
765 "<tbody><tr class='diffchunk'>\n", -1);
766 }
767
768 /* MergeBuilderHtml::xEnd() */
769 static void htmlEnd(MergeBuilder *p){
770 MergeBuilderHtml *pH = (MergeBuilderHtml*)p;
771

Keyboard Shortcuts

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