@matheusbsbs / matheus-bagliano / commits / e439e092b8
Fork 0

gitk: Arrange to kill diff-files & diff-index on quit

Local change analysis can take a noticeable amount of time on large file sets, and produce no output if there are no changes. Register the back-ends in commfd, so that they get properly killed on window close. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Jul 13, 2008 at 16:40 UTC e439e092b8ee5248e92ed4cb4400f9dbed70f689
1 file changed +23 -16
gitk
+23 -16
@@ -90,6 +90,15 @@ proc dorunq {} {
90 }
91 }
92
93 +proc reg_instance {fd} {
94 + global commfd leftover loginstance
95 +
96 + set i [incr loginstance]
97 + set commfd($i) $fd
98 + set leftover($i) {}
99 + return $i
100 +}
101 +
102 proc unmerged_files {files} {
103 global nr_unmerged
104
@@ -294,10 +303,10 @@ proc parseviewrevs {view revs} {
303 # Start off a git log process and arrange to read its output
304 proc start_rev_list {view} {
305 global startmsecs commitidx viewcomplete curview
297 - global commfd leftover tclencoding
306 + global tclencoding
307 global viewargs viewargscmd viewfiles vfilelimit
308 global showlocalchanges commitinterest
300 - global viewactive loginstance viewinstances vmergeonly
309 + global viewactive viewinstances vmergeonly
310 global pending_select mainheadid
311 global vcanopt vflags vrevs vorigargs
312
@@ -354,10 +363,8 @@ proc start_rev_list {view} {
363 error_popup "[mc "Error executing git log:"] $err"
364 return 0
365 }
357 - set i [incr loginstance]
366 + set i [reg_instance $fd]
367 set viewinstances($view) [list $i]
359 - set commfd($i) $fd
360 - set leftover($i) {}
368 if {$showlocalchanges && $mainheadid ne {}} {
369 lappend commitinterest($mainheadid) {dodiffindex}
370 }
@@ -420,8 +427,8 @@ proc getcommits {} {
427
428 proc updatecommits {} {
429 global curview vcanopt vorigargs vfilelimit viewinstances
423 - global viewactive viewcomplete loginstance tclencoding
424 - global startmsecs commfd showneartags showlocalchanges leftover
430 + global viewactive viewcomplete tclencoding
431 + global startmsecs showneartags showlocalchanges
432 global mainheadid pending_select
433 global isworktree
434 global varcid vposids vnegids vflags vrevs
@@ -482,10 +489,8 @@ proc updatecommits {} {
489 if {$viewactive($view) == 0} {
490 set startmsecs [clock clicks -milliseconds]
491 }
485 - set i [incr loginstance]
492 + set i [reg_instance $fd]
493 lappend viewinstances($view) $i
487 - set commfd($i) $fd
488 - set leftover($i) {}
494 fconfigure $fd -blocking 0 -translation lf -eofchar {}
495 if {$tclencoding != {}} {
496 fconfigure $fd -encoding $tclencoding
@@ -4063,10 +4068,11 @@ proc dodiffindex {} {
4068 incr lserial
4069 set fd [open "|git diff-index --cached HEAD" r]
4070 fconfigure $fd -blocking 0
4066 - filerun $fd [list readdiffindex $fd $lserial]
4071 + set i [reg_instance $fd]
4072 + filerun $fd [list readdiffindex $fd $lserial $i]
4073 }
4074
4069 -proc readdiffindex {fd serial} {
4075 +proc readdiffindex {fd serial inst} {
4076 global mainheadid nullid nullid2 curview commitinfo commitdata lserial
4077
4078 set isdiff 1
@@ -4077,7 +4083,7 @@ proc readdiffindex {fd serial} {
4083 set isdiff 0
4084 }
4085 # we only need to see one line and we don't really care what it says...
4080 - close $fd
4086 + stop_instance $inst
4087
4088 if {$serial != $lserial} {
4089 return 0
@@ -4086,7 +4092,8 @@ proc readdiffindex {fd serial} {
4092 # now see if there are any local changes not checked in to the index
4093 set fd [open "|git diff-files" r]
4094 fconfigure $fd -blocking 0
4089 - filerun $fd [list readdifffiles $fd $serial]
4095 + set i [reg_instance $fd]
4096 + filerun $fd [list readdifffiles $fd $serial $i]
4097
4098 if {$isdiff && ![commitinview $nullid2 $curview]} {
4099 # add the line for the changes in the index to the graph
@@ -4103,7 +4110,7 @@ proc readdiffindex {fd serial} {
4110 return 0
4111 }
4112
4106 -proc readdifffiles {fd serial} {
4113 +proc readdifffiles {fd serial inst} {
4114 global mainheadid nullid nullid2 curview
4115 global commitinfo commitdata lserial
4116
@@ -4115,7 +4122,7 @@ proc readdifffiles {fd serial} {
4122 set isdiff 0
4123 }
4124 # we only need to see one line and we don't really care what it says...
4118 - close $fd
4125 + stop_instance $inst
4126
4127 if {$serial != $lserial} {
4128 return 0