Fossil SCM
Add chunk numbers to each row of the diff output for HTML diffs.
Commit
8caab6155eb40cfb2516f3eddf80cbe117705006f40f040e6c885775af8d8224
Parent
63a5c754fd8d343…
1 file changed
+9
-2
+9
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -99,10 +99,15 @@ | ||
| 99 | 99 | /* |
| 100 | 100 | ** Length of a dline |
| 101 | 101 | */ |
| 102 | 102 | #define LENGTH(X) ((X)->n) |
| 103 | 103 | |
| 104 | +/* | |
| 105 | +** Number of diff chunks generated | |
| 106 | +*/ | |
| 107 | +static int nChunk = 0; | |
| 108 | + | |
| 104 | 109 | /* |
| 105 | 110 | ** A context for running a raw diff. |
| 106 | 111 | ** |
| 107 | 112 | ** The aEdit[] array describes the raw diff. Each triple of integers in |
| 108 | 113 | ** aEdit[] means: |
| @@ -1412,11 +1417,12 @@ | ||
| 1412 | 1417 | blob_append_xfer(p->pOut, &p->aCol[2]); |
| 1413 | 1418 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1414 | 1419 | } |
| 1415 | 1420 | static void dfunifiedStartRow(DiffBuilder *p){ |
| 1416 | 1421 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1417 | - blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1); | |
| 1422 | + blob_appendf(p->pOut,"<tr id=\"chunk%d\">" | |
| 1423 | + "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); | |
| 1418 | 1424 | p->eState = 0; |
| 1419 | 1425 | p->nPending = 0; |
| 1420 | 1426 | } |
| 1421 | 1427 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1422 | 1428 | dfunifiedFinishRow(p); |
| @@ -1624,11 +1630,12 @@ | ||
| 1624 | 1630 | blob_append_xfer(p->pOut, &p->aCol[3]); |
| 1625 | 1631 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1626 | 1632 | } |
| 1627 | 1633 | static void dfsplitStartRow(DiffBuilder *p){ |
| 1628 | 1634 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1629 | - blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1); | |
| 1635 | + blob_appendf(p->pOut,"<tr id=\"chunk%d\">" | |
| 1636 | + "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); | |
| 1630 | 1637 | p->eState = 0; |
| 1631 | 1638 | } |
| 1632 | 1639 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1633 | 1640 | dfsplitFinishRow(p); |
| 1634 | 1641 | blob_append(p->pOut, |
| 1635 | 1642 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -99,10 +99,15 @@ | |
| 99 | /* |
| 100 | ** Length of a dline |
| 101 | */ |
| 102 | #define LENGTH(X) ((X)->n) |
| 103 | |
| 104 | /* |
| 105 | ** A context for running a raw diff. |
| 106 | ** |
| 107 | ** The aEdit[] array describes the raw diff. Each triple of integers in |
| 108 | ** aEdit[] means: |
| @@ -1412,11 +1417,12 @@ | |
| 1412 | blob_append_xfer(p->pOut, &p->aCol[2]); |
| 1413 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1414 | } |
| 1415 | static void dfunifiedStartRow(DiffBuilder *p){ |
| 1416 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1417 | blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1); |
| 1418 | p->eState = 0; |
| 1419 | p->nPending = 0; |
| 1420 | } |
| 1421 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1422 | dfunifiedFinishRow(p); |
| @@ -1624,11 +1630,12 @@ | |
| 1624 | blob_append_xfer(p->pOut, &p->aCol[3]); |
| 1625 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1626 | } |
| 1627 | static void dfsplitStartRow(DiffBuilder *p){ |
| 1628 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1629 | blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1); |
| 1630 | p->eState = 0; |
| 1631 | } |
| 1632 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1633 | dfsplitFinishRow(p); |
| 1634 | blob_append(p->pOut, |
| 1635 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -99,10 +99,15 @@ | |
| 99 | /* |
| 100 | ** Length of a dline |
| 101 | */ |
| 102 | #define LENGTH(X) ((X)->n) |
| 103 | |
| 104 | /* |
| 105 | ** Number of diff chunks generated |
| 106 | */ |
| 107 | static int nChunk = 0; |
| 108 | |
| 109 | /* |
| 110 | ** A context for running a raw diff. |
| 111 | ** |
| 112 | ** The aEdit[] array describes the raw diff. Each triple of integers in |
| 113 | ** aEdit[] means: |
| @@ -1412,11 +1417,12 @@ | |
| 1417 | blob_append_xfer(p->pOut, &p->aCol[2]); |
| 1418 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1419 | } |
| 1420 | static void dfunifiedStartRow(DiffBuilder *p){ |
| 1421 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1422 | blob_appendf(p->pOut,"<tr id=\"chunk%d\">" |
| 1423 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1424 | p->eState = 0; |
| 1425 | p->nPending = 0; |
| 1426 | } |
| 1427 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1428 | dfunifiedFinishRow(p); |
| @@ -1624,11 +1630,12 @@ | |
| 1630 | blob_append_xfer(p->pOut, &p->aCol[3]); |
| 1631 | blob_append(p->pOut, "</pre></td></tr>\n", -1); |
| 1632 | } |
| 1633 | static void dfsplitStartRow(DiffBuilder *p){ |
| 1634 | if( blob_size(&p->aCol[0])>0 ) return; |
| 1635 | blob_appendf(p->pOut,"<tr id=\"chunk%d\">" |
| 1636 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1637 | p->eState = 0; |
| 1638 | } |
| 1639 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1640 | dfsplitFinishRow(p); |
| 1641 | blob_append(p->pOut, |
| 1642 |