Fossil SCM
When HTML diffs are generated from a webpage, include sufficient information in class names ids, and data- elements to permit JS to redraw the separators to include context fill-in buttons.
Commit
c275a166b351d2b122ded0bbcfc0039c026f54db870faf19a7a08b3ca435d09b
Parent
85ca2fe5b588e28…
2 files changed
+45
-12
+3
+45
-12
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -96,10 +96,11 @@ | ||
| 96 | 96 | int wColumn; /* Column width in -y mode */ |
| 97 | 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | + const char *zLeftHash; /* HASH-id of the left file */ | |
| 101 | 102 | }; |
| 102 | 103 | |
| 103 | 104 | #endif /* INTERFACE */ |
| 104 | 105 | |
| 105 | 106 | /* |
| @@ -897,10 +898,11 @@ | ||
| 897 | 898 | unsigned int nPending; /* Number of pending lines */ |
| 898 | 899 | int eState; /* State of the output */ |
| 899 | 900 | int width; /* Display width */ |
| 900 | 901 | Blob *pOut; /* Output blob */ |
| 901 | 902 | Blob aCol[5]; /* Holding blobs */ |
| 903 | + DiffConfig *pCfg; /* Configuration information */ | |
| 902 | 904 | }; |
| 903 | 905 | |
| 904 | 906 | /************************* DiffBuilderDebug ********************************/ |
| 905 | 907 | /* This version of DiffBuilder is used for debugging the diff and diff |
| 906 | 908 | ** diff formatter logic. It is accessed using the (undocumented) --debug |
| @@ -1251,11 +1253,20 @@ | ||
| 1251 | 1253 | blob_appendf(p->pOut,"<tr id=\"chunk%d\">" |
| 1252 | 1254 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1253 | 1255 | } |
| 1254 | 1256 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1255 | 1257 | dfunifiedFinishRow(p); |
| 1256 | - blob_append(p->pOut, "<tr><td class=\"diffln difflne\">" | |
| 1258 | + if( p->pCfg && p->pCfg->zLeftHash ){ | |
| 1259 | + blob_appendf(p->pOut, | |
| 1260 | + "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" | |
| 1261 | + " id=\"skip%xh%xi%x\">\n", | |
| 1262 | + p->lnLeft+1, p->lnLeft+n, | |
| 1263 | + nChunk, p->lnLeft, n); | |
| 1264 | + }else{ | |
| 1265 | + blob_append(p->pOut, "<tr>", 4); | |
| 1266 | + } | |
| 1267 | + blob_append(p->pOut, "<td class=\"diffln difflne\">" | |
| 1257 | 1268 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1258 | 1269 | p->lnLeft += n; |
| 1259 | 1270 | p->lnRight += n; |
| 1260 | 1271 | } |
| 1261 | 1272 | static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ |
| @@ -1372,11 +1383,11 @@ | ||
| 1372 | 1383 | static void dfunifiedEnd(DiffBuilder *p){ |
| 1373 | 1384 | dfunifiedFinishRow(p); |
| 1374 | 1385 | blob_append(p->pOut, "</table>\n",-1); |
| 1375 | 1386 | fossil_free(p); |
| 1376 | 1387 | } |
| 1377 | -static DiffBuilder *dfunifiedNew(Blob *pOut){ | |
| 1388 | +static DiffBuilder *dfunifiedNew(Blob *pOut, DiffConfig *pCfg){ | |
| 1378 | 1389 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1379 | 1390 | p->xSkip = dfunifiedSkip; |
| 1380 | 1391 | p->xCommon = dfunifiedCommon; |
| 1381 | 1392 | p->xInsert = dfunifiedInsert; |
| 1382 | 1393 | p->xDelete = dfunifiedDelete; |
| @@ -1385,16 +1396,22 @@ | ||
| 1385 | 1396 | p->xEnd = dfunifiedEnd; |
| 1386 | 1397 | p->lnLeft = p->lnRight = 0; |
| 1387 | 1398 | p->eState = 0; |
| 1388 | 1399 | p->nPending = 0; |
| 1389 | 1400 | p->pOut = pOut; |
| 1390 | - blob_append(pOut, "<table class=\"diff udiff\">\n", -1); | |
| 1401 | + if( pCfg->zLeftHash ){ | |
| 1402 | + blob_appendf(pOut, "<table class=\"diff udiff\" data-lefthash=\"%s\">\n", | |
| 1403 | + pCfg->zLeftHash); | |
| 1404 | + }else{ | |
| 1405 | + blob_append(pOut, "<table class=\"diff udiff\">\n", -1); | |
| 1406 | + } | |
| 1391 | 1407 | blob_init(&p->aCol[0], 0, 0); |
| 1392 | 1408 | blob_init(&p->aCol[1], 0, 0); |
| 1393 | 1409 | blob_init(&p->aCol[2], 0, 0); |
| 1394 | 1410 | blob_init(&p->aCol[3], 0, 0); |
| 1395 | 1411 | blob_init(&p->aCol[4], 0, 0); |
| 1412 | + p->pCfg = pCfg; | |
| 1396 | 1413 | return p; |
| 1397 | 1414 | } |
| 1398 | 1415 | |
| 1399 | 1416 | /************************* DiffBuilderSplit ******************************/ |
| 1400 | 1417 | /* This formatter creates a side-by-side diff in HTML. The output is a |
| @@ -1463,15 +1480,24 @@ | ||
| 1463 | 1480 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1464 | 1481 | p->eState = 0; |
| 1465 | 1482 | } |
| 1466 | 1483 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1467 | 1484 | dfsplitFinishRow(p); |
| 1468 | - blob_append(p->pOut, | |
| 1469 | - "<tr><td class=\"diffln difflnl difflne\">︙</td>" | |
| 1470 | - "<td></td><td></td>" | |
| 1471 | - "<td class=\"diffln difflnr difflne\">︙</td>" | |
| 1472 | - "<td/td></tr>\n", -1); | |
| 1485 | + if( p->pCfg && p->pCfg->zLeftHash ){ | |
| 1486 | + blob_appendf(p->pOut, | |
| 1487 | + "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" | |
| 1488 | + " id=\"skip%xh%xi%x\">\n", | |
| 1489 | + p->lnLeft+1, p->lnLeft+n, | |
| 1490 | + nChunk,p->lnLeft,n); | |
| 1491 | + }else{ | |
| 1492 | + blob_append(p->pOut, "<tr>", 4); | |
| 1493 | + } | |
| 1494 | + blob_append(p->pOut, | |
| 1495 | + "<td class=\"diffln difflnl difflne\">︙</td>" | |
| 1496 | + "<td></td><td></td>" | |
| 1497 | + "<td class=\"diffln difflnr difflne\">︙</td>" | |
| 1498 | + "<td/td></tr>\n", -1); | |
| 1473 | 1499 | p->lnLeft += n; |
| 1474 | 1500 | p->lnRight += n; |
| 1475 | 1501 | } |
| 1476 | 1502 | static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ |
| 1477 | 1503 | dfsplitStartRow(p); |
| @@ -1580,11 +1606,11 @@ | ||
| 1580 | 1606 | static void dfsplitEnd(DiffBuilder *p){ |
| 1581 | 1607 | dfsplitFinishRow(p); |
| 1582 | 1608 | blob_append(p->pOut, "</table>\n",-1); |
| 1583 | 1609 | fossil_free(p); |
| 1584 | 1610 | } |
| 1585 | -static DiffBuilder *dfsplitNew(Blob *pOut){ | |
| 1611 | +static DiffBuilder *dfsplitNew(Blob *pOut, DiffConfig *pCfg){ | |
| 1586 | 1612 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1587 | 1613 | p->xSkip = dfsplitSkip; |
| 1588 | 1614 | p->xCommon = dfsplitCommon; |
| 1589 | 1615 | p->xInsert = dfsplitInsert; |
| 1590 | 1616 | p->xDelete = dfsplitDelete; |
| @@ -1592,16 +1618,23 @@ | ||
| 1592 | 1618 | p->xEdit = dfsplitEdit; |
| 1593 | 1619 | p->xEnd = dfsplitEnd; |
| 1594 | 1620 | p->lnLeft = p->lnRight = 0; |
| 1595 | 1621 | p->eState = 0; |
| 1596 | 1622 | p->pOut = pOut; |
| 1597 | - blob_append(pOut, "<table class=\"diff splitdiff\">\n", -1); | |
| 1623 | + if( pCfg->zLeftHash ){ | |
| 1624 | + blob_appendf(pOut, | |
| 1625 | + "<table class=\"diff splitdiff\" data-lefthash=\"%s\">\n", | |
| 1626 | + pCfg->zLeftHash); | |
| 1627 | + }else{ | |
| 1628 | + blob_append(pOut, "<table class=\"diff splitdiff\">\n", -1); | |
| 1629 | + } | |
| 1598 | 1630 | blob_init(&p->aCol[0], 0, 0); |
| 1599 | 1631 | blob_init(&p->aCol[1], 0, 0); |
| 1600 | 1632 | blob_init(&p->aCol[2], 0, 0); |
| 1601 | 1633 | blob_init(&p->aCol[3], 0, 0); |
| 1602 | 1634 | blob_init(&p->aCol[4], 0, 0); |
| 1635 | + p->pCfg = pCfg; | |
| 1603 | 1636 | return p; |
| 1604 | 1637 | } |
| 1605 | 1638 | |
| 1606 | 1639 | /************************* DiffBuilderSbs ******************************/ |
| 1607 | 1640 | /* This formatter creates a side-by-side diff in text. |
| @@ -2714,20 +2747,20 @@ | ||
| 2714 | 2747 | DiffBuilder *pBuilder = dftclNew(pOut); |
| 2715 | 2748 | formatDiff(&c, pCfg, pBuilder); |
| 2716 | 2749 | }else if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 2717 | 2750 | DiffBuilder *pBuilder; |
| 2718 | 2751 | if( pCfg->diffFlags & DIFF_HTML ){ |
| 2719 | - pBuilder = dfsplitNew(pOut); | |
| 2752 | + pBuilder = dfsplitNew(pOut, pCfg); | |
| 2720 | 2753 | }else{ |
| 2721 | 2754 | pBuilder = dfsbsNew(pOut, pCfg); |
| 2722 | 2755 | } |
| 2723 | 2756 | formatDiff(&c, pCfg, pBuilder); |
| 2724 | 2757 | }else if( pCfg->diffFlags & DIFF_DEBUG ){ |
| 2725 | 2758 | DiffBuilder *pBuilder = dfdebugNew(pOut); |
| 2726 | 2759 | formatDiff(&c, pCfg, pBuilder); |
| 2727 | 2760 | }else if( pCfg->diffFlags & DIFF_HTML ){ |
| 2728 | - DiffBuilder *pBuilder = dfunifiedNew(pOut); | |
| 2761 | + DiffBuilder *pBuilder = dfunifiedNew(pOut, pCfg); | |
| 2729 | 2762 | formatDiff(&c, pCfg, pBuilder); |
| 2730 | 2763 | }else{ |
| 2731 | 2764 | contextDiff(&c, pOut, pCfg); |
| 2732 | 2765 | } |
| 2733 | 2766 | fossil_free(c.aFrom); |
| 2734 | 2767 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | int wColumn; /* Column width in -y mode */ |
| 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | }; |
| 102 | |
| 103 | #endif /* INTERFACE */ |
| 104 | |
| 105 | /* |
| @@ -897,10 +898,11 @@ | |
| 897 | unsigned int nPending; /* Number of pending lines */ |
| 898 | int eState; /* State of the output */ |
| 899 | int width; /* Display width */ |
| 900 | Blob *pOut; /* Output blob */ |
| 901 | Blob aCol[5]; /* Holding blobs */ |
| 902 | }; |
| 903 | |
| 904 | /************************* DiffBuilderDebug ********************************/ |
| 905 | /* This version of DiffBuilder is used for debugging the diff and diff |
| 906 | ** diff formatter logic. It is accessed using the (undocumented) --debug |
| @@ -1251,11 +1253,20 @@ | |
| 1251 | blob_appendf(p->pOut,"<tr id=\"chunk%d\">" |
| 1252 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1253 | } |
| 1254 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1255 | dfunifiedFinishRow(p); |
| 1256 | blob_append(p->pOut, "<tr><td class=\"diffln difflne\">" |
| 1257 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1258 | p->lnLeft += n; |
| 1259 | p->lnRight += n; |
| 1260 | } |
| 1261 | static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ |
| @@ -1372,11 +1383,11 @@ | |
| 1372 | static void dfunifiedEnd(DiffBuilder *p){ |
| 1373 | dfunifiedFinishRow(p); |
| 1374 | blob_append(p->pOut, "</table>\n",-1); |
| 1375 | fossil_free(p); |
| 1376 | } |
| 1377 | static DiffBuilder *dfunifiedNew(Blob *pOut){ |
| 1378 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1379 | p->xSkip = dfunifiedSkip; |
| 1380 | p->xCommon = dfunifiedCommon; |
| 1381 | p->xInsert = dfunifiedInsert; |
| 1382 | p->xDelete = dfunifiedDelete; |
| @@ -1385,16 +1396,22 @@ | |
| 1385 | p->xEnd = dfunifiedEnd; |
| 1386 | p->lnLeft = p->lnRight = 0; |
| 1387 | p->eState = 0; |
| 1388 | p->nPending = 0; |
| 1389 | p->pOut = pOut; |
| 1390 | blob_append(pOut, "<table class=\"diff udiff\">\n", -1); |
| 1391 | blob_init(&p->aCol[0], 0, 0); |
| 1392 | blob_init(&p->aCol[1], 0, 0); |
| 1393 | blob_init(&p->aCol[2], 0, 0); |
| 1394 | blob_init(&p->aCol[3], 0, 0); |
| 1395 | blob_init(&p->aCol[4], 0, 0); |
| 1396 | return p; |
| 1397 | } |
| 1398 | |
| 1399 | /************************* DiffBuilderSplit ******************************/ |
| 1400 | /* This formatter creates a side-by-side diff in HTML. The output is a |
| @@ -1463,15 +1480,24 @@ | |
| 1463 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1464 | p->eState = 0; |
| 1465 | } |
| 1466 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1467 | dfsplitFinishRow(p); |
| 1468 | blob_append(p->pOut, |
| 1469 | "<tr><td class=\"diffln difflnl difflne\">︙</td>" |
| 1470 | "<td></td><td></td>" |
| 1471 | "<td class=\"diffln difflnr difflne\">︙</td>" |
| 1472 | "<td/td></tr>\n", -1); |
| 1473 | p->lnLeft += n; |
| 1474 | p->lnRight += n; |
| 1475 | } |
| 1476 | static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ |
| 1477 | dfsplitStartRow(p); |
| @@ -1580,11 +1606,11 @@ | |
| 1580 | static void dfsplitEnd(DiffBuilder *p){ |
| 1581 | dfsplitFinishRow(p); |
| 1582 | blob_append(p->pOut, "</table>\n",-1); |
| 1583 | fossil_free(p); |
| 1584 | } |
| 1585 | static DiffBuilder *dfsplitNew(Blob *pOut){ |
| 1586 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1587 | p->xSkip = dfsplitSkip; |
| 1588 | p->xCommon = dfsplitCommon; |
| 1589 | p->xInsert = dfsplitInsert; |
| 1590 | p->xDelete = dfsplitDelete; |
| @@ -1592,16 +1618,23 @@ | |
| 1592 | p->xEdit = dfsplitEdit; |
| 1593 | p->xEnd = dfsplitEnd; |
| 1594 | p->lnLeft = p->lnRight = 0; |
| 1595 | p->eState = 0; |
| 1596 | p->pOut = pOut; |
| 1597 | blob_append(pOut, "<table class=\"diff splitdiff\">\n", -1); |
| 1598 | blob_init(&p->aCol[0], 0, 0); |
| 1599 | blob_init(&p->aCol[1], 0, 0); |
| 1600 | blob_init(&p->aCol[2], 0, 0); |
| 1601 | blob_init(&p->aCol[3], 0, 0); |
| 1602 | blob_init(&p->aCol[4], 0, 0); |
| 1603 | return p; |
| 1604 | } |
| 1605 | |
| 1606 | /************************* DiffBuilderSbs ******************************/ |
| 1607 | /* This formatter creates a side-by-side diff in text. |
| @@ -2714,20 +2747,20 @@ | |
| 2714 | DiffBuilder *pBuilder = dftclNew(pOut); |
| 2715 | formatDiff(&c, pCfg, pBuilder); |
| 2716 | }else if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 2717 | DiffBuilder *pBuilder; |
| 2718 | if( pCfg->diffFlags & DIFF_HTML ){ |
| 2719 | pBuilder = dfsplitNew(pOut); |
| 2720 | }else{ |
| 2721 | pBuilder = dfsbsNew(pOut, pCfg); |
| 2722 | } |
| 2723 | formatDiff(&c, pCfg, pBuilder); |
| 2724 | }else if( pCfg->diffFlags & DIFF_DEBUG ){ |
| 2725 | DiffBuilder *pBuilder = dfdebugNew(pOut); |
| 2726 | formatDiff(&c, pCfg, pBuilder); |
| 2727 | }else if( pCfg->diffFlags & DIFF_HTML ){ |
| 2728 | DiffBuilder *pBuilder = dfunifiedNew(pOut); |
| 2729 | formatDiff(&c, pCfg, pBuilder); |
| 2730 | }else{ |
| 2731 | contextDiff(&c, pOut, pCfg); |
| 2732 | } |
| 2733 | fossil_free(c.aFrom); |
| 2734 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | int wColumn; /* Column width in -y mode */ |
| 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | const char *zLeftHash; /* HASH-id of the left file */ |
| 102 | }; |
| 103 | |
| 104 | #endif /* INTERFACE */ |
| 105 | |
| 106 | /* |
| @@ -897,10 +898,11 @@ | |
| 898 | unsigned int nPending; /* Number of pending lines */ |
| 899 | int eState; /* State of the output */ |
| 900 | int width; /* Display width */ |
| 901 | Blob *pOut; /* Output blob */ |
| 902 | Blob aCol[5]; /* Holding blobs */ |
| 903 | DiffConfig *pCfg; /* Configuration information */ |
| 904 | }; |
| 905 | |
| 906 | /************************* DiffBuilderDebug ********************************/ |
| 907 | /* This version of DiffBuilder is used for debugging the diff and diff |
| 908 | ** diff formatter logic. It is accessed using the (undocumented) --debug |
| @@ -1251,11 +1253,20 @@ | |
| 1253 | blob_appendf(p->pOut,"<tr id=\"chunk%d\">" |
| 1254 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1255 | } |
| 1256 | static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1257 | dfunifiedFinishRow(p); |
| 1258 | if( p->pCfg && p->pCfg->zLeftHash ){ |
| 1259 | blob_appendf(p->pOut, |
| 1260 | "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" |
| 1261 | " id=\"skip%xh%xi%x\">\n", |
| 1262 | p->lnLeft+1, p->lnLeft+n, |
| 1263 | nChunk, p->lnLeft, n); |
| 1264 | }else{ |
| 1265 | blob_append(p->pOut, "<tr>", 4); |
| 1266 | } |
| 1267 | blob_append(p->pOut, "<td class=\"diffln difflne\">" |
| 1268 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1269 | p->lnLeft += n; |
| 1270 | p->lnRight += n; |
| 1271 | } |
| 1272 | static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ |
| @@ -1372,11 +1383,11 @@ | |
| 1383 | static void dfunifiedEnd(DiffBuilder *p){ |
| 1384 | dfunifiedFinishRow(p); |
| 1385 | blob_append(p->pOut, "</table>\n",-1); |
| 1386 | fossil_free(p); |
| 1387 | } |
| 1388 | static DiffBuilder *dfunifiedNew(Blob *pOut, DiffConfig *pCfg){ |
| 1389 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1390 | p->xSkip = dfunifiedSkip; |
| 1391 | p->xCommon = dfunifiedCommon; |
| 1392 | p->xInsert = dfunifiedInsert; |
| 1393 | p->xDelete = dfunifiedDelete; |
| @@ -1385,16 +1396,22 @@ | |
| 1396 | p->xEnd = dfunifiedEnd; |
| 1397 | p->lnLeft = p->lnRight = 0; |
| 1398 | p->eState = 0; |
| 1399 | p->nPending = 0; |
| 1400 | p->pOut = pOut; |
| 1401 | if( pCfg->zLeftHash ){ |
| 1402 | blob_appendf(pOut, "<table class=\"diff udiff\" data-lefthash=\"%s\">\n", |
| 1403 | pCfg->zLeftHash); |
| 1404 | }else{ |
| 1405 | blob_append(pOut, "<table class=\"diff udiff\">\n", -1); |
| 1406 | } |
| 1407 | blob_init(&p->aCol[0], 0, 0); |
| 1408 | blob_init(&p->aCol[1], 0, 0); |
| 1409 | blob_init(&p->aCol[2], 0, 0); |
| 1410 | blob_init(&p->aCol[3], 0, 0); |
| 1411 | blob_init(&p->aCol[4], 0, 0); |
| 1412 | p->pCfg = pCfg; |
| 1413 | return p; |
| 1414 | } |
| 1415 | |
| 1416 | /************************* DiffBuilderSplit ******************************/ |
| 1417 | /* This formatter creates a side-by-side diff in HTML. The output is a |
| @@ -1463,15 +1480,24 @@ | |
| 1480 | "<td class=\"diffln difflnl\"><pre>\n", ++nChunk); |
| 1481 | p->eState = 0; |
| 1482 | } |
| 1483 | static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1484 | dfsplitFinishRow(p); |
| 1485 | if( p->pCfg && p->pCfg->zLeftHash ){ |
| 1486 | blob_appendf(p->pOut, |
| 1487 | "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" |
| 1488 | " id=\"skip%xh%xi%x\">\n", |
| 1489 | p->lnLeft+1, p->lnLeft+n, |
| 1490 | nChunk,p->lnLeft,n); |
| 1491 | }else{ |
| 1492 | blob_append(p->pOut, "<tr>", 4); |
| 1493 | } |
| 1494 | blob_append(p->pOut, |
| 1495 | "<td class=\"diffln difflnl difflne\">︙</td>" |
| 1496 | "<td></td><td></td>" |
| 1497 | "<td class=\"diffln difflnr difflne\">︙</td>" |
| 1498 | "<td/td></tr>\n", -1); |
| 1499 | p->lnLeft += n; |
| 1500 | p->lnRight += n; |
| 1501 | } |
| 1502 | static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ |
| 1503 | dfsplitStartRow(p); |
| @@ -1580,11 +1606,11 @@ | |
| 1606 | static void dfsplitEnd(DiffBuilder *p){ |
| 1607 | dfsplitFinishRow(p); |
| 1608 | blob_append(p->pOut, "</table>\n",-1); |
| 1609 | fossil_free(p); |
| 1610 | } |
| 1611 | static DiffBuilder *dfsplitNew(Blob *pOut, DiffConfig *pCfg){ |
| 1612 | DiffBuilder *p = fossil_malloc(sizeof(*p)); |
| 1613 | p->xSkip = dfsplitSkip; |
| 1614 | p->xCommon = dfsplitCommon; |
| 1615 | p->xInsert = dfsplitInsert; |
| 1616 | p->xDelete = dfsplitDelete; |
| @@ -1592,16 +1618,23 @@ | |
| 1618 | p->xEdit = dfsplitEdit; |
| 1619 | p->xEnd = dfsplitEnd; |
| 1620 | p->lnLeft = p->lnRight = 0; |
| 1621 | p->eState = 0; |
| 1622 | p->pOut = pOut; |
| 1623 | if( pCfg->zLeftHash ){ |
| 1624 | blob_appendf(pOut, |
| 1625 | "<table class=\"diff splitdiff\" data-lefthash=\"%s\">\n", |
| 1626 | pCfg->zLeftHash); |
| 1627 | }else{ |
| 1628 | blob_append(pOut, "<table class=\"diff splitdiff\">\n", -1); |
| 1629 | } |
| 1630 | blob_init(&p->aCol[0], 0, 0); |
| 1631 | blob_init(&p->aCol[1], 0, 0); |
| 1632 | blob_init(&p->aCol[2], 0, 0); |
| 1633 | blob_init(&p->aCol[3], 0, 0); |
| 1634 | blob_init(&p->aCol[4], 0, 0); |
| 1635 | p->pCfg = pCfg; |
| 1636 | return p; |
| 1637 | } |
| 1638 | |
| 1639 | /************************* DiffBuilderSbs ******************************/ |
| 1640 | /* This formatter creates a side-by-side diff in text. |
| @@ -2714,20 +2747,20 @@ | |
| 2747 | DiffBuilder *pBuilder = dftclNew(pOut); |
| 2748 | formatDiff(&c, pCfg, pBuilder); |
| 2749 | }else if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 2750 | DiffBuilder *pBuilder; |
| 2751 | if( pCfg->diffFlags & DIFF_HTML ){ |
| 2752 | pBuilder = dfsplitNew(pOut, pCfg); |
| 2753 | }else{ |
| 2754 | pBuilder = dfsbsNew(pOut, pCfg); |
| 2755 | } |
| 2756 | formatDiff(&c, pCfg, pBuilder); |
| 2757 | }else if( pCfg->diffFlags & DIFF_DEBUG ){ |
| 2758 | DiffBuilder *pBuilder = dfdebugNew(pOut); |
| 2759 | formatDiff(&c, pCfg, pBuilder); |
| 2760 | }else if( pCfg->diffFlags & DIFF_HTML ){ |
| 2761 | DiffBuilder *pBuilder = dfunifiedNew(pOut, pCfg); |
| 2762 | formatDiff(&c, pCfg, pBuilder); |
| 2763 | }else{ |
| 2764 | contextDiff(&c, pOut, pCfg); |
| 2765 | } |
| 2766 | fossil_free(c.aFrom); |
| 2767 |
+3
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -338,12 +338,14 @@ | ||
| 338 | 338 | int toid; |
| 339 | 339 | Blob from, to; |
| 340 | 340 | if( zFrom ){ |
| 341 | 341 | fromid = uuid_to_rid(zFrom, 0); |
| 342 | 342 | content_get(fromid, &from); |
| 343 | + pCfg->zLeftHash = zFrom; | |
| 343 | 344 | }else{ |
| 344 | 345 | blob_zero(&from); |
| 346 | + pCfg->zLeftHash = 0; | |
| 345 | 347 | } |
| 346 | 348 | if( zTo ){ |
| 347 | 349 | toid = uuid_to_rid(zTo, 0); |
| 348 | 350 | content_get(toid, &to); |
| 349 | 351 | }else{ |
| @@ -353,10 +355,11 @@ | ||
| 353 | 355 | pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
| 354 | 356 | }else{ |
| 355 | 357 | pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
| 356 | 358 | } |
| 357 | 359 | text_diff(&from, &to, cgi_output_blob(), pCfg); |
| 360 | + pCfg->zLeftHash = 0; | |
| 358 | 361 | blob_reset(&from); |
| 359 | 362 | blob_reset(&to); |
| 360 | 363 | } |
| 361 | 364 | |
| 362 | 365 | /* |
| 363 | 366 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -338,12 +338,14 @@ | |
| 338 | int toid; |
| 339 | Blob from, to; |
| 340 | if( zFrom ){ |
| 341 | fromid = uuid_to_rid(zFrom, 0); |
| 342 | content_get(fromid, &from); |
| 343 | }else{ |
| 344 | blob_zero(&from); |
| 345 | } |
| 346 | if( zTo ){ |
| 347 | toid = uuid_to_rid(zTo, 0); |
| 348 | content_get(toid, &to); |
| 349 | }else{ |
| @@ -353,10 +355,11 @@ | |
| 353 | pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
| 354 | }else{ |
| 355 | pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
| 356 | } |
| 357 | text_diff(&from, &to, cgi_output_blob(), pCfg); |
| 358 | blob_reset(&from); |
| 359 | blob_reset(&to); |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -338,12 +338,14 @@ | |
| 338 | int toid; |
| 339 | Blob from, to; |
| 340 | if( zFrom ){ |
| 341 | fromid = uuid_to_rid(zFrom, 0); |
| 342 | content_get(fromid, &from); |
| 343 | pCfg->zLeftHash = zFrom; |
| 344 | }else{ |
| 345 | blob_zero(&from); |
| 346 | pCfg->zLeftHash = 0; |
| 347 | } |
| 348 | if( zTo ){ |
| 349 | toid = uuid_to_rid(zTo, 0); |
| 350 | content_get(toid, &to); |
| 351 | }else{ |
| @@ -353,10 +355,11 @@ | |
| 355 | pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
| 356 | }else{ |
| 357 | pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
| 358 | } |
| 359 | text_diff(&from, &to, cgi_output_blob(), pCfg); |
| 360 | pCfg->zLeftHash = 0; |
| 361 | blob_reset(&from); |
| 362 | blob_reset(&to); |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 |