@matheusbsbs / matheus-bagliano / commits / 468bcaedbb
Fork 0

gitk: Don't filter view arguments through git rev-parse

Previously we passed the arguments indicating what commits the user wants to view through git rev-parse to get a list of IDs (positive and negative), then gave that to git log. This had a couple of problems, notably that --merge and --left-right didn't get handled properly. Instead we now just pass the original arguments to git log. When doing an update, we append --not followed by the list of commits we have seen that have no children, since we have got (or will get) their ancestors from the first git log. If the first git log isn't finished yet, we might get some duplicates from the second git log, but that doesn't cause any problem. Also get rid of the unused vnextroot variable. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Mar 3, 2008 at 10:19 UTC 468bcaedbb1589f16955e63b6bfba01c2f53e433
1 file changed +22 -47
gitk
+22 -47
@@ -94,30 +94,21 @@ proc dorunq {} {
94 proc start_rev_list {view} {
95 global startmsecs
96 global commfd leftover tclencoding datemode
97 - global viewargs viewfiles commitidx viewcomplete vnextroot
97 + global viewargs viewfiles commitidx viewcomplete
98 global showlocalchanges commitinterest mainheadid
99 global progressdirn progresscoords proglastnc curview
100 - global viewincl viewactive loginstance viewinstances
100 + global viewactive loginstance viewinstances
101 global pending_select mainheadid
102
103 set startmsecs [clock clicks -milliseconds]
104 set commitidx($view) 0
105 set viewcomplete($view) 0
106 set viewactive($view) 1
107 - set vnextroot($view) 0
107 varcinit $view
108
110 - set commits [eval exec git rev-parse --default HEAD --revs-only \
111 - $viewargs($view)]
112 - set viewincl($view) {}
113 - foreach c $commits {
114 - if {[regexp {^[0-9a-fA-F]{40}$} $c]} {
115 - lappend viewincl($view) $c
116 - }
117 - }
109 if {[catch {
110 set fd [open [concat | git log --no-color -z --pretty=raw --parents \
120 - --boundary $commits "--" $viewfiles($view)] r]
111 + --boundary $viewargs($view) "--" $viewfiles($view)] r]
112 } err]} {
113 error_popup "[mc "Error executing git log:"] $err"
114 exit 1
@@ -170,9 +161,9 @@ proc getcommits {} {
161 }
162
163 proc updatecommits {} {
173 - global curview viewargs viewfiles viewincl viewinstances
164 + global curview viewargs viewfiles viewinstances
165 global viewactive viewcomplete loginstance tclencoding mainheadid
175 - global varcid startmsecs commfd showneartags showlocalchanges leftover
166 + global startmsecs commfd showneartags showlocalchanges leftover
167 global mainheadid pending_select
168
169 set oldmainid $mainheadid
@@ -186,33 +177,10 @@ proc updatecommits {} {
177 }
178 }
179 set view $curview
189 - set commits [exec git rev-parse --default HEAD --revs-only \
190 - $viewargs($view)]
191 - set pos {}
192 - set neg {}
193 - set flags {}
194 - foreach c $commits {
195 - if {[string match "^*" $c]} {
196 - lappend neg $c
197 - } elseif {[regexp {^[0-9a-fA-F]{40}$} $c]} {
198 - if {!([info exists varcid($view,$c)] ||
199 - [lsearch -exact $viewincl($view) $c] >= 0)} {
200 - lappend pos $c
201 - }
202 - } else {
203 - lappend flags $c
204 - }
205 - }
206 - if {$pos eq {}} {
207 - return
208 - }
209 - foreach id $viewincl($view) {
210 - lappend neg "^$id"
211 - }
212 - set viewincl($view) [concat $viewincl($view) $pos]
180 if {[catch {
181 set fd [open [concat | git log --no-color -z --pretty=raw --parents \
215 - --boundary $pos $neg $flags "--" $viewfiles($view)] r]
182 + --boundary $viewargs($view) --not [seeds $view] \
183 + "--" $viewfiles($view)] r]
184 } err]} {
185 error_popup "Error executing git log: $err"
186 exit 1
@@ -322,6 +290,19 @@ proc resetvarcs {view} {
290 catch {unset ordertok}
291 }
292
293 +# returns a list of the commits with no children
294 +proc seeds {v} {
295 + global vdownptr vleftptr varcstart
296 +
297 + set ret {}
298 + set a [lindex $vdownptr($v) 0]
299 + while {$a != 0} {
300 + lappend ret [lindex $varcstart($v) $a]
301 + set a [lindex $vleftptr($v) $a]
302 + }
303 + return $ret
304 +}
305 +
306 proc newvarc {view id} {
307 global varcid varctok parents children datemode
308 global vupptr vdownptr vleftptr vbackptr varcrow varcix varcstart
@@ -1000,7 +981,7 @@ proc getcommitlines {fd inst view updating} {
981 global cmitlisted commitinterest leftover
982 global commitidx commitdata datemode
983 global parents children curview hlview
1003 - global vnextroot idpending ordertok
984 + global idpending ordertok
985 global varccommits varcid varctok vtokmod viewfiles
986
987 set stuff [read $fd 500000]
@@ -7103,7 +7084,7 @@ proc mkbrgo {top} {
7084 }
7085
7086 proc cherrypick {} {
7106 - global rowmenuid curview viewincl
7087 + global rowmenuid curview
7088 global mainhead mainheadid
7089
7090 set oldhead [exec git rev-parse HEAD]
@@ -7137,12 +7118,6 @@ proc cherrypick {} {
7118 movedhead $newhead $mainhead
7119 set mainheadid $newhead
7120 }
7140 - # remove oldhead from viewincl and add newhead
7141 - set i [lsearch -exact $viewincl($curview) $oldhead]
7142 - if {$i >= 0} {
7143 - set viewincl($curview) [lreplace $viewincl($curview) $i $i]
7144 - }
7145 - lappend viewincl($curview) $newhead
7121 redrawtags $oldhead
7122 redrawtags $newhead
7123 selbyid $newhead