Fossil SCM

When using "fossil test-diff" with -y or --tk, show the names of both input files above their respective columns.

drh 2014-02-27 18:34 trunk
Commit 1e0e0753f6946c731befd7df9681c9d9100dfe28
1 file changed +20 -6
+20 -6
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -49,15 +49,25 @@
4949
if( diffFlags & DIFF_BRIEF ){
5050
/* no-op */
5151
}else if( diffFlags & DIFF_SIDEBYSIDE ){
5252
int w = diff_width(diffFlags);
5353
int n1 = strlen(zLeft);
54
- int x;
55
- if( n1>w*2 ) n1 = w*2;
56
- x = w*2+17 - (n1+2);
57
- z = mprintf("%.*c %.*s %.*c\n",
58
- x/2, '=', n1, zLeft, (x+1)/2, '=');
54
+ int n2 = strlen(zRight);
55
+ int x, x2;
56
+ if( n1==n2 && fossil_strcmp(zLeft,zRight)==0 ){
57
+ if( n1>w*2 ) n1 = w*2;
58
+ x = w*2+17 - (n1+2);
59
+ z = mprintf("%.*c %.*s %.*c\n",
60
+ x/2, '=', n1, zLeft, (x+1)/2, '=');
61
+ }else{
62
+ if( w<20 ) w = 20;
63
+ if( n1>w-10 ) n1 = w - 10;
64
+ if( n2>w-10 ) n2 = w - 10;
65
+ z = mprintf("%.*c %.*s %.*c versus %.*c %.*s %.*c\n",
66
+ (w-n1+10)/2, '=', n1, zLeft, (w-n1+1)/2, '=',
67
+ (w-n2)/2, '=', n2, zRight, (w-n2+1)/2, '=');
68
+ }
5969
}else{
6070
z = mprintf("--- %s\n+++ %s\n", zLeft, zRight);
6171
}
6272
fossil_print("%s", z);
6373
fossil_free(z);
@@ -664,11 +674,14 @@
664674
@ set N [llength $difftxt]
665675
@ set ii 0
666676
@ set nDiffs 0
667677
@ array set widths {txt 0 ln 0 mkr 0}
668678
@ while {[set line [getLine $difftxt $N ii]] != -1} {
669
-@ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
679
+@ set fn2 {}
680
+@ if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2]
681
+@ && ![regexp {^=+ (.*?) =+$} $line all fn]
682
+@ } {
670683
@ continue
671684
@ }
672685
@ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} {
673686
@ continue
674687
@ }
@@ -682,10 +695,11 @@
682695
@ if {$nDiffs > 1} {
683696
@ $c insert end \n -
684697
@ }
685698
@ if {[colType $c] eq "txt"} {
686699
@ $c insert end $fn\n fn
700
+@ if {$fn2!=""} {set fn $fn2}
687701
@ } else {
688702
@ $c insert end \n fn
689703
@ }
690704
@ $c insert end \n -
691705
@
692706
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -49,15 +49,25 @@
49 if( diffFlags & DIFF_BRIEF ){
50 /* no-op */
51 }else if( diffFlags & DIFF_SIDEBYSIDE ){
52 int w = diff_width(diffFlags);
53 int n1 = strlen(zLeft);
54 int x;
55 if( n1>w*2 ) n1 = w*2;
56 x = w*2+17 - (n1+2);
57 z = mprintf("%.*c %.*s %.*c\n",
58 x/2, '=', n1, zLeft, (x+1)/2, '=');
 
 
 
 
 
 
 
 
 
 
59 }else{
60 z = mprintf("--- %s\n+++ %s\n", zLeft, zRight);
61 }
62 fossil_print("%s", z);
63 fossil_free(z);
@@ -664,11 +674,14 @@
664 @ set N [llength $difftxt]
665 @ set ii 0
666 @ set nDiffs 0
667 @ array set widths {txt 0 ln 0 mkr 0}
668 @ while {[set line [getLine $difftxt $N ii]] != -1} {
669 @ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
 
 
 
670 @ continue
671 @ }
672 @ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} {
673 @ continue
674 @ }
@@ -682,10 +695,11 @@
682 @ if {$nDiffs > 1} {
683 @ $c insert end \n -
684 @ }
685 @ if {[colType $c] eq "txt"} {
686 @ $c insert end $fn\n fn
 
687 @ } else {
688 @ $c insert end \n fn
689 @ }
690 @ $c insert end \n -
691 @
692
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -49,15 +49,25 @@
49 if( diffFlags & DIFF_BRIEF ){
50 /* no-op */
51 }else if( diffFlags & DIFF_SIDEBYSIDE ){
52 int w = diff_width(diffFlags);
53 int n1 = strlen(zLeft);
54 int n2 = strlen(zRight);
55 int x, x2;
56 if( n1==n2 && fossil_strcmp(zLeft,zRight)==0 ){
57 if( n1>w*2 ) n1 = w*2;
58 x = w*2+17 - (n1+2);
59 z = mprintf("%.*c %.*s %.*c\n",
60 x/2, '=', n1, zLeft, (x+1)/2, '=');
61 }else{
62 if( w<20 ) w = 20;
63 if( n1>w-10 ) n1 = w - 10;
64 if( n2>w-10 ) n2 = w - 10;
65 z = mprintf("%.*c %.*s %.*c versus %.*c %.*s %.*c\n",
66 (w-n1+10)/2, '=', n1, zLeft, (w-n1+1)/2, '=',
67 (w-n2)/2, '=', n2, zRight, (w-n2+1)/2, '=');
68 }
69 }else{
70 z = mprintf("--- %s\n+++ %s\n", zLeft, zRight);
71 }
72 fossil_print("%s", z);
73 fossil_free(z);
@@ -664,11 +674,14 @@
674 @ set N [llength $difftxt]
675 @ set ii 0
676 @ set nDiffs 0
677 @ array set widths {txt 0 ln 0 mkr 0}
678 @ while {[set line [getLine $difftxt $N ii]] != -1} {
679 @ set fn2 {}
680 @ if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2]
681 @ && ![regexp {^=+ (.*?) =+$} $line all fn]
682 @ } {
683 @ continue
684 @ }
685 @ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} {
686 @ continue
687 @ }
@@ -682,10 +695,11 @@
695 @ if {$nDiffs > 1} {
696 @ $c insert end \n -
697 @ }
698 @ if {[colType $c] eq "txt"} {
699 @ $c insert end $fn\n fn
700 @ if {$fn2!=""} {set fn $fn2}
701 @ } else {
702 @ $c insert end \n fn
703 @ }
704 @ $c insert end \n -
705 @
706

Keyboard Shortcuts

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