Index: src/diff.c
==================================================================
--- src/diff.c
+++ src/diff.c
@@ -96,10 +96,11 @@
int wColumn; /* Column width in -y mode */
u32 nFile; /* Number of files diffed so far */
const char *zDiffCmd; /* External diff command to use instead of builtin */
const char *zBinGlob; /* GLOB pattern for binary files */
ReCompiled *pRe; /* Show only changes matching this pattern */
+ const char *zLeftHash; /* HASH-id of the left file */
};
#endif /* INTERFACE */
/*
@@ -897,10 +898,11 @@
unsigned int nPending; /* Number of pending lines */
int eState; /* State of the output */
int width; /* Display width */
Blob *pOut; /* Output blob */
Blob aCol[5]; /* Holding blobs */
+ DiffConfig *pCfg; /* Configuration information */
};
/************************* DiffBuilderDebug ********************************/
/* This version of DiffBuilder is used for debugging the diff and diff
** diff formatter logic. It is accessed using the (undocumented) --debug
@@ -1251,11 +1253,20 @@
blob_appendf(p->pOut,"
"
"\n", ++nChunk);
}
static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){
dfunifiedFinishRow(p);
- blob_append(p->pOut, ""
+ if( p->pCfg && p->pCfg->zLeftHash ){
+ blob_appendf(p->pOut,
+ " | \n",
+ p->lnLeft+1, p->lnLeft+n,
+ nChunk, p->lnLeft, n);
+ }else{
+ blob_append(p->pOut, " ", 4);
+ }
+ blob_append(p->pOut, ""
"︙ | | | \n", -1);
p->lnLeft += n;
p->lnRight += n;
}
static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){
@@ -1372,11 +1383,11 @@
static void dfunifiedEnd(DiffBuilder *p){
dfunifiedFinishRow(p);
blob_append(p->pOut, "\n",-1);
fossil_free(p);
}
-static DiffBuilder *dfunifiedNew(Blob *pOut){
+static DiffBuilder *dfunifiedNew(Blob *pOut, DiffConfig *pCfg){
DiffBuilder *p = fossil_malloc(sizeof(*p));
p->xSkip = dfunifiedSkip;
p->xCommon = dfunifiedCommon;
p->xInsert = dfunifiedInsert;
p->xDelete = dfunifiedDelete;
@@ -1385,16 +1396,22 @@
p->xEnd = dfunifiedEnd;
p->lnLeft = p->lnRight = 0;
p->eState = 0;
p->nPending = 0;
p->pOut = pOut;
- blob_append(pOut, " \n", -1);
+ if( pCfg->zLeftHash ){
+ blob_appendf(pOut, "\n",
+ pCfg->zLeftHash);
+ }else{
+ blob_append(pOut, "\n", -1);
+ }
blob_init(&p->aCol[0], 0, 0);
blob_init(&p->aCol[1], 0, 0);
blob_init(&p->aCol[2], 0, 0);
blob_init(&p->aCol[3], 0, 0);
blob_init(&p->aCol[4], 0, 0);
+ p->pCfg = pCfg;
return p;
}
/************************* DiffBuilderSplit ******************************/
/* This formatter creates a side-by-side diff in HTML. The output is a
@@ -1463,15 +1480,24 @@
"\n", ++nChunk);
p->eState = 0;
}
static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){
dfsplitFinishRow(p);
- blob_append(p->pOut,
- "︙ | "
- " | | "
- "︙ | "
- " | \n", -1);
+ if( p->pCfg && p->pCfg->zLeftHash ){
+ blob_appendf(p->pOut,
+ "\n",
+ p->lnLeft+1, p->lnLeft+n,
+ nChunk,p->lnLeft,n);
+ }else{
+ blob_append(p->pOut, " ", 4);
+ }
+ blob_append(p->pOut,
+ "︙ | "
+ " | | "
+ "︙ | "
+ " | \n", -1);
p->lnLeft += n;
p->lnRight += n;
}
static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){
dfsplitStartRow(p);
@@ -1580,11 +1606,11 @@
static void dfsplitEnd(DiffBuilder *p){
dfsplitFinishRow(p);
blob_append(p->pOut, " | \n",-1);
fossil_free(p);
}
-static DiffBuilder *dfsplitNew(Blob *pOut){
+static DiffBuilder *dfsplitNew(Blob *pOut, DiffConfig *pCfg){
DiffBuilder *p = fossil_malloc(sizeof(*p));
p->xSkip = dfsplitSkip;
p->xCommon = dfsplitCommon;
p->xInsert = dfsplitInsert;
p->xDelete = dfsplitDelete;
@@ -1592,16 +1618,23 @@
p->xEdit = dfsplitEdit;
p->xEnd = dfsplitEnd;
p->lnLeft = p->lnRight = 0;
p->eState = 0;
p->pOut = pOut;
- blob_append(pOut, "\n", -1);
+ if( pCfg->zLeftHash ){
+ blob_appendf(pOut,
+ "\n",
+ pCfg->zLeftHash);
+ }else{
+ blob_append(pOut, "\n", -1);
+ }
blob_init(&p->aCol[0], 0, 0);
blob_init(&p->aCol[1], 0, 0);
blob_init(&p->aCol[2], 0, 0);
blob_init(&p->aCol[3], 0, 0);
blob_init(&p->aCol[4], 0, 0);
+ p->pCfg = pCfg;
return p;
}
/************************* DiffBuilderSbs ******************************/
/* This formatter creates a side-by-side diff in text.
@@ -2714,20 +2747,20 @@
DiffBuilder *pBuilder = dftclNew(pOut);
formatDiff(&c, pCfg, pBuilder);
}else if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){
DiffBuilder *pBuilder;
if( pCfg->diffFlags & DIFF_HTML ){
- pBuilder = dfsplitNew(pOut);
+ pBuilder = dfsplitNew(pOut, pCfg);
}else{
pBuilder = dfsbsNew(pOut, pCfg);
}
formatDiff(&c, pCfg, pBuilder);
}else if( pCfg->diffFlags & DIFF_DEBUG ){
DiffBuilder *pBuilder = dfdebugNew(pOut);
formatDiff(&c, pCfg, pBuilder);
}else if( pCfg->diffFlags & DIFF_HTML ){
- DiffBuilder *pBuilder = dfunifiedNew(pOut);
+ DiffBuilder *pBuilder = dfunifiedNew(pOut, pCfg);
formatDiff(&c, pCfg, pBuilder);
}else{
contextDiff(&c, pOut, pCfg);
}
fossil_free(c.aFrom);
Index: src/info.c
==================================================================
--- src/info.c
+++ src/info.c
@@ -338,12 +338,14 @@
int toid;
Blob from, to;
if( zFrom ){
fromid = uuid_to_rid(zFrom, 0);
content_get(fromid, &from);
+ pCfg->zLeftHash = zFrom;
}else{
blob_zero(&from);
+ pCfg->zLeftHash = 0;
}
if( zTo ){
toid = uuid_to_rid(zTo, 0);
content_get(toid, &to);
}else{
@@ -353,10 +355,11 @@
pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG;
}else{
pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
}
text_diff(&from, &to, cgi_output_blob(), pCfg);
+ pCfg->zLeftHash = 0;
blob_reset(&from);
blob_reset(&to);
}
/*
|