175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
const char *zV2; /* Label or name for the V2 file */
const char *zOut; /* Label or name for the output */
Blob *pPivot; /* The common ancestor */
Blob *pV1; /* First variant */
Blob *pV2; /* Second variant */
Blob *pOut; /* Write merge results here */
int useCrLf; /* Use CRLF line endings */
unsigned int lnPivot; /* Lines read from pivot */
unsigned int lnV1; /* Lines read from v1 */
unsigned int lnV2; /* Lines read from v2 */
unsigned int lnOut; /* Lines written to out */
unsigned int nConflict; /* Number of conflicts seen */
};
|
>
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
const char *zV2; /* Label or name for the V2 file */
const char *zOut; /* Label or name for the output */
Blob *pPivot; /* The common ancestor */
Blob *pV1; /* First variant */
Blob *pV2; /* Second variant */
Blob *pOut; /* Write merge results here */
int useCrLf; /* Use CRLF line endings */
int nContext; /* Size of unchanged line boundaries */
unsigned int lnPivot; /* Lines read from pivot */
unsigned int lnV1; /* Lines read from v1 */
unsigned int lnV2; /* Lines read from v2 */
unsigned int lnOut; /* Lines written to out */
unsigned int nConflict; /* Number of conflicts seen */
};
|
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
** respectively. The first character of each token provides auxiliary
** information:
**
** . This line is omitted.
** T Literal text follows that should have a \n terminator.
** R Literal text follows that needs a \r\n terminator.
** Z Literal text without a line terminator.
** 1 Text is a copy of token 1
** 2 Use data from data-token 2
** 3 Use data from data-token 3
*/
/* Copy one line of text from pIn and append to pOut, encoded as TCL */
static void tclLineOfText(Blob *pOut, Blob *pIn){
|
>
|
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
** respectively. The first character of each token provides auxiliary
** information:
**
** . This line is omitted.
** T Literal text follows that should have a \n terminator.
** R Literal text follows that needs a \r\n terminator.
** Z Literal text without a line terminator.
** S Skipped lines in all 4 files.
** 1 Text is a copy of token 1
** 2 Use data from data-token 2
** 3 Use data from data-token 3
*/
/* Copy one line of text from pIn and append to pOut, encoded as TCL */
static void tclLineOfText(Blob *pOut, Blob *pIn){
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
blob_append_char(pOut, c);
}
}
pIn->iCursor = i;
blob_append_char(pOut, '"');
}
static void tclSame(MergeBuilder *p, unsigned int N){
int i;
for(i=0; i<N; i++){
tclLineOfText(p->pOut, p->pPivot);
blob_append(p->pOut, " 1 1 1\n", 7);
}
p->lnPivot += N;
p->lnV1 += N;
p->lnV2 += N;
blob_copy_lines(0, p->pV1, N);
blob_copy_lines(0, p->pV2, N);
}
static void tclChngV1(MergeBuilder *p, unsigned int nPivot, unsigned int nV1){
|
|
>
|
>
>
|
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
blob_append_char(pOut, c);
}
}
pIn->iCursor = i;
blob_append_char(pOut, '"');
}
static void tclSame(MergeBuilder *p, unsigned int N){
int i = 0;
int nSkip;
if( p->lnPivot>=2 || p->lnV1>2 || p->lnV2>2 ){
while( i<N && i<p->nContext ){
tclLineOfText(p->pOut, p->pPivot);
blob_append(p->pOut, " 1 1 1\n", 7);
i++;
}
nSkip = N - p->nContext*2;
}else{
nSkip = N - p->nContext;
}
if( nSkip>0 ){
blob_appendf(p->pOut, "S%d . . .\n", nSkip);
blob_copy_lines(0, p->pPivot, nSkip);
i += nSkip;
}
while( i<N ){
tclLineOfText(p->pOut, p->pPivot);
blob_append(p->pOut, " 1 1 1\n", 7);
i++;
}
p->lnPivot += N;
p->lnV1 += N;
p->lnV2 += N;
blob_copy_lines(0, p->pV1, N);
blob_copy_lines(0, p->pV2, N);
}
static void tclChngV1(MergeBuilder *p, unsigned int nPivot, unsigned int nV1){
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
static void mergebuilder_init_tcl(MergeBuilder *p){
mergebuilder_init(p);
p->xSame = tclSame;
p->xChngV1 = tclChngV1;
p->xChngV2 = tclChngV2;
p->xChngBoth = tclChngBoth;
p->xConflict = tclConflict;
}
/*****************************************************************************/
/*
** aC[] is an "edit triple" for changes from A to B. Advance through
** this triple to determine the number of lines to bypass on B in order
** to match an advance of sz lines on A.
|
>
|
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
static void mergebuilder_init_tcl(MergeBuilder *p){
mergebuilder_init(p);
p->xSame = tclSame;
p->xChngV1 = tclChngV1;
p->xChngV2 = tclChngV2;
p->xChngBoth = tclChngBoth;
p->xConflict = tclConflict;
p->nContext = 6;
}
/*****************************************************************************/
/*
** aC[] is an "edit triple" for changes from A to B. Advance through
** this triple to determine the number of lines to bypass on B in order
** to match an advance of sz lines on A.
|
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
|
if( find_option("debug", 0, 0) ){
mergebuilder_init(&s);
}
if( find_option("tcl", 0, 0) ){
mergebuilder_init_tcl(&s);
noWarn = 1;
}
flagTk = find_option("tk", 0, 0);
blob_zero(&pivot); s.pPivot = &pivot;
blob_zero(&v1); s.pV1 = &v1;
blob_zero(&v2); s.pV2 = &v2;
blob_zero(&out); s.pOut = &out;
/* We should be done with options.. */
verify_all_options();
|
|
|
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
|
if( find_option("debug", 0, 0) ){
mergebuilder_init(&s);
}
if( find_option("tcl", 0, 0) ){
mergebuilder_init_tcl(&s);
noWarn = 1;
}
flagTk = find_option("tk", 0, 0)!=0;
blob_zero(&pivot); s.pPivot = &pivot;
blob_zero(&v1); s.pV1 = &v1;
blob_zero(&v2); s.pV2 = &v2;
blob_zero(&out); s.pOut = &out;
/* We should be done with options.. */
verify_all_options();
|