Fossil SCM

Get the --tk option working with the new --tcl format.

drh 2021-09-02 10:09 diff-color-enhancements
Commit 63610f3f2733b6c3b2d8fba03a7885cd81844c057bf5218b5b47e15587376977
2 files changed +72 -55 +2 -1
+72 -55
--- src/diff.tcl
+++ src/diff.tcl
@@ -70,68 +70,85 @@
7070
close $in
7171
}
7272
set N [llength $difftxt]
7373
set ii 0
7474
set nDiffs 0
75
+ set n1 0
76
+ set n2 0
7577
array set widths {txt 0 ln 0 mkr 0}
7678
while {[set line [getLine $difftxt $N ii]] != -1} {
77
- set fn2 {}
78
- if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2]
79
- && ![regexp {^=+ (.*?) =+$} $line all fn]
80
- } {
81
- continue
82
- }
83
- set errMsg ""
84
- set line [getLine $difftxt $N ii]
85
- if {[string compare -length 6 $line "<table"]
86
- && ![regexp {<p[^>]*>(.+)} $line - errMsg]} {
87
- continue
88
- }
8979
incr nDiffs
90
- set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
91
- .wfiles.lb insert end $fn
92
-
93
- foreach c [cols] {
94
- if {$nDiffs > 1} {
95
- $c insert end \n -
96
- }
97
- if {[colType $c] eq "txt"} {
98
- $c insert end $fn\n fn
99
- if {$fn2!=""} {set fn $fn2}
100
- } else {
101
- $c insert end \n fn
102
- }
103
- $c insert end \n -
104
-
105
- if {$errMsg ne ""} continue
106
- while {[getLine $difftxt $N ii] ne "<pre>"} continue
107
- set type [colType $c]
108
- set str {}
109
- while {[set line [getLine $difftxt $N ii]] ne "</pre>"} {
110
- set len [string length [dehtml $line]]
111
- if {$len > $widths($type)} {
112
- set widths($type) $len
113
- }
114
- append str $line\n
115
- }
116
-
117
- set re {<span class="diff([a-z]+)">([^<]*)</span>}
118
- # Use \r as separator since it can't appear in the diff output (it gets
119
- # converted to a space).
120
- set str [regsub -all $re $str "\r\\1\r\\2\r"]
121
- foreach {pre class mid} [split $str \r] {
122
- if {$class ne ""} {
123
- $c insert end [dehtml $pre] - [dehtml $mid] [list $class -]
124
- } else {
125
- $c insert end [dehtml $pre] -
126
- }
127
- }
128
- }
129
-
130
- if {$errMsg ne ""} {
131
- foreach c {.txtA .txtB} {$c insert end [string trim $errMsg] err}
132
- foreach c [cols] {$c insert end \n -}
80
+ switch -- [lindex $line 0] {
81
+ FILE {
82
+ .lnA insert end \n fn \n -
83
+ .txtA insert end [lindex $line 1] fn \n -
84
+ .mkr insert end \n fn \n -
85
+ .lnB insert end \n fn \n -
86
+ .txtB insert end [lindex $line 2] fn \n -
87
+ set n1 0
88
+ set n2 0
89
+ }
90
+ SKIP {
91
+ set n [lindex $line 1]
92
+ incr n1 $n
93
+ incr n2 $n
94
+ }
95
+ COM {
96
+ set x [lindex $line 1]
97
+ incr n1
98
+ incr n2
99
+ .lnA insert end $n1\n -
100
+ .txtA insert end $x\n -
101
+ .mkr insert end \n -
102
+ .lnB insert end $n2\n -
103
+ .txtB insert end $x\n -
104
+ }
105
+ INS {
106
+ set x [lindex $line 1]
107
+ incr n2
108
+ .lnA insert end \n -
109
+ .txtA insert end \n -
110
+ .mkr insert end >\n -
111
+ .lnB insert end $n2\n -
112
+ .txtB insert end $x add \n -
113
+ }
114
+ DEL {
115
+ set x [lindex $line 1]
116
+ incr n1
117
+ .lnA insert end $n1\n -
118
+ .txtA insert end $x rm \n -
119
+ .mkr insert end <\n -
120
+ .lnB insert end \n -
121
+ .txtB insert end \n -
122
+ }
123
+ EDIT {
124
+ incr n1
125
+ incr n2
126
+ .lnA insert end $n1\n -
127
+ .lnB insert end $n2\n -
128
+ .mkr insert end |\n -
129
+ set nn [llength $line]
130
+ for {set i 1} {$i<$nn} {incr i 3} {
131
+ set x [lindex $line $i]
132
+ if {$x ne ""} {
133
+ .txtA insert end $x -
134
+ .txtB insert end $x -
135
+ }
136
+ if {$i+2<$nn} {
137
+ .txtA insert end [lindex $line [expr {$i+1}]] chng
138
+ .txtB insert end [lindex $line [expr {$i+2}]] chng
139
+ }
140
+ }
141
+ .txtA insert end \n -
142
+ .txtB insert end \n -
143
+ }
144
+ "" {
145
+ incr nDiffs -1
146
+ }
147
+ default {
148
+ error "bad diff source line: $line"
149
+ }
133150
}
134151
}
135152
136153
foreach c [cols] {
137154
set type [colType $c]
138155
--- src/diff.tcl
+++ src/diff.tcl
@@ -70,68 +70,85 @@
70 close $in
71 }
72 set N [llength $difftxt]
73 set ii 0
74 set nDiffs 0
 
 
75 array set widths {txt 0 ln 0 mkr 0}
76 while {[set line [getLine $difftxt $N ii]] != -1} {
77 set fn2 {}
78 if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2]
79 && ![regexp {^=+ (.*?) =+$} $line all fn]
80 } {
81 continue
82 }
83 set errMsg ""
84 set line [getLine $difftxt $N ii]
85 if {[string compare -length 6 $line "<table"]
86 && ![regexp {<p[^>]*>(.+)} $line - errMsg]} {
87 continue
88 }
89 incr nDiffs
90 set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
91 .wfiles.lb insert end $fn
92
93 foreach c [cols] {
94 if {$nDiffs > 1} {
95 $c insert end \n -
96 }
97 if {[colType $c] eq "txt"} {
98 $c insert end $fn\n fn
99 if {$fn2!=""} {set fn $fn2}
100 } else {
101 $c insert end \n fn
102 }
103 $c insert end \n -
104
105 if {$errMsg ne ""} continue
106 while {[getLine $difftxt $N ii] ne "<pre>"} continue
107 set type [colType $c]
108 set str {}
109 while {[set line [getLine $difftxt $N ii]] ne "</pre>"} {
110 set len [string length [dehtml $line]]
111 if {$len > $widths($type)} {
112 set widths($type) $len
113 }
114 append str $line\n
115 }
116
117 set re {<span class="diff([a-z]+)">([^<]*)</span>}
118 # Use \r as separator since it can't appear in the diff output (it gets
119 # converted to a space).
120 set str [regsub -all $re $str "\r\\1\r\\2\r"]
121 foreach {pre class mid} [split $str \r] {
122 if {$class ne ""} {
123 $c insert end [dehtml $pre] - [dehtml $mid] [list $class -]
124 } else {
125 $c insert end [dehtml $pre] -
126 }
127 }
128 }
129
130 if {$errMsg ne ""} {
131 foreach c {.txtA .txtB} {$c insert end [string trim $errMsg] err}
132 foreach c [cols] {$c insert end \n -}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133 }
134 }
135
136 foreach c [cols] {
137 set type [colType $c]
138
--- src/diff.tcl
+++ src/diff.tcl
@@ -70,68 +70,85 @@
70 close $in
71 }
72 set N [llength $difftxt]
73 set ii 0
74 set nDiffs 0
75 set n1 0
76 set n2 0
77 array set widths {txt 0 ln 0 mkr 0}
78 while {[set line [getLine $difftxt $N ii]] != -1} {
 
 
 
 
 
 
 
 
 
 
 
 
79 incr nDiffs
80 switch -- [lindex $line 0] {
81 FILE {
82 .lnA insert end \n fn \n -
83 .txtA insert end [lindex $line 1] fn \n -
84 .mkr insert end \n fn \n -
85 .lnB insert end \n fn \n -
86 .txtB insert end [lindex $line 2] fn \n -
87 set n1 0
88 set n2 0
89 }
90 SKIP {
91 set n [lindex $line 1]
92 incr n1 $n
93 incr n2 $n
94 }
95 COM {
96 set x [lindex $line 1]
97 incr n1
98 incr n2
99 .lnA insert end $n1\n -
100 .txtA insert end $x\n -
101 .mkr insert end \n -
102 .lnB insert end $n2\n -
103 .txtB insert end $x\n -
104 }
105 INS {
106 set x [lindex $line 1]
107 incr n2
108 .lnA insert end \n -
109 .txtA insert end \n -
110 .mkr insert end >\n -
111 .lnB insert end $n2\n -
112 .txtB insert end $x add \n -
113 }
114 DEL {
115 set x [lindex $line 1]
116 incr n1
117 .lnA insert end $n1\n -
118 .txtA insert end $x rm \n -
119 .mkr insert end <\n -
120 .lnB insert end \n -
121 .txtB insert end \n -
122 }
123 EDIT {
124 incr n1
125 incr n2
126 .lnA insert end $n1\n -
127 .lnB insert end $n2\n -
128 .mkr insert end |\n -
129 set nn [llength $line]
130 for {set i 1} {$i<$nn} {incr i 3} {
131 set x [lindex $line $i]
132 if {$x ne ""} {
133 .txtA insert end $x -
134 .txtB insert end $x -
135 }
136 if {$i+2<$nn} {
137 .txtA insert end [lindex $line [expr {$i+1}]] chng
138 .txtB insert end [lindex $line [expr {$i+2}]] chng
139 }
140 }
141 .txtA insert end \n -
142 .txtB insert end \n -
143 }
144 "" {
145 incr nDiffs -1
146 }
147 default {
148 error "bad diff source line: $line"
149 }
150 }
151 }
152
153 foreach c [cols] {
154 set type [colType $c]
155
+2 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -937,12 +937,13 @@
937937
Blob script;
938938
const char *zTempFile = 0;
939939
char *zCmd;
940940
const char *zTclsh;
941941
blob_zero(&script);
942
- blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
942
+ blob_appendf(&script, "set fossilcmd {| \"%/\" %s -tcl -i -v",
943943
g.nameOfExe, zSubCmd);
944
+ find_option("tcl",0,0);
944945
find_option("html",0,0);
945946
find_option("side-by-side","y",0);
946947
find_option("internal","i",0);
947948
find_option("verbose","v",0);
948949
zTclsh = find_option("tclsh",0,1);
949950
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -937,12 +937,13 @@
937 Blob script;
938 const char *zTempFile = 0;
939 char *zCmd;
940 const char *zTclsh;
941 blob_zero(&script);
942 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
943 g.nameOfExe, zSubCmd);
 
944 find_option("html",0,0);
945 find_option("side-by-side","y",0);
946 find_option("internal","i",0);
947 find_option("verbose","v",0);
948 zTclsh = find_option("tclsh",0,1);
949
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -937,12 +937,13 @@
937 Blob script;
938 const char *zTempFile = 0;
939 char *zCmd;
940 const char *zTclsh;
941 blob_zero(&script);
942 blob_appendf(&script, "set fossilcmd {| \"%/\" %s -tcl -i -v",
943 g.nameOfExe, zSubCmd);
944 find_option("tcl",0,0);
945 find_option("html",0,0);
946 find_option("side-by-side","y",0);
947 find_option("internal","i",0);
948 find_option("verbose","v",0);
949 zTclsh = find_option("tclsh",0,1);
950

Keyboard Shortcuts

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