@matheusbsbs / matheus-bagliano / commits / 24f7a667e6
Fork 0

gitk: More bug fixes and cleanups

* Add/remove fake commits (for local changes) when updating the view even if nothing else has changed. * Get rid of unused getdbg variable. * Get rid of vseeds and uat. * Fix bug where removerow would throw a "no such element in array" error. * Clear out cached highlights when line numbers change. * Make dodiffindex remove the fake commit rows if they currently exist but there are now no local changes. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Dec 19, 2007 at 09:35 UTC 24f7a667e69262525beba726dded2fb221d9be27
1 file changed +39 -39
gitk
+39 -39
@@ -168,10 +168,12 @@ proc getcommits {} {
168
169 proc updatecommits {} {
170 global curview viewargs viewfiles viewincl viewinstances
171 - global viewactive viewcomplete loginstance tclencoding
172 - global varcid startmsecs commfd getdbg showneartags leftover
171 + global viewactive viewcomplete loginstance tclencoding mainheadid
172 + global varcid startmsecs commfd showneartags showlocalchanges leftover
173
174 - set getdbg 1
174 + if {$showlocalchanges && [commitinview $mainheadid $curview]} {
175 + dodiffindex
176 + }
177 set view $curview
178 set commits [exec git rev-parse --default HEAD --revs-only \
179 $viewargs($view)]
@@ -267,10 +269,9 @@ proc strrep {n} {
269 # --topo-order) into the order for display.
270
271 proc varcinit {view} {
270 - global vseeds varcstart vupptr vdownptr vleftptr varctok varcrow
271 - global vtokmod varcmod vrowmod varcix uat
272 + global varcstart vupptr vdownptr vleftptr varctok varcrow
273 + global vtokmod varcmod vrowmod varcix
274
273 - set vseeds($view) {}
275 set varcstart($view) {{}}
276 set vupptr($view) {0}
277 set vdownptr($view) {0}
@@ -281,7 +282,6 @@ proc varcinit {view} {
282 set varcmod($view) 0
283 set vrowmod($view) 0
284 set varcix($view) {{}}
284 - set uat 0
285 }
286
287 proc resetvarcs {view} {
@@ -306,7 +306,7 @@ proc resetvarcs {view} {
306 }
307
308 proc newvarc {view id} {
309 - global varcid varctok parents children vseeds
309 + global varcid varctok parents children
310 global vupptr vdownptr vleftptr varcrow varcix varcstart
311 global commitdata commitinfo vseedcount varccommits
312
@@ -326,7 +326,6 @@ proc newvarc {view id} {
326 set c [incr vseedcount($view,$cdate)]
327 set cdate [expr {$cdate ^ 0xffffffff}]
328 set tok "s[strrep $cdate][strrep $c]"
329 - lappend vseeds($view) $id
329 lappend vupptr($view) 0
330 set ka [lindex $vdownptr($view) 0]
331 if {$ka == 0 ||
@@ -508,24 +507,17 @@ proc renumbervarc {a v} {
507 }
508
509 proc fix_reversal {p a v} {
511 - global varcid varcstart varctok vupptr vseeds
510 + global varcid varcstart varctok vupptr
511
512 set pa $varcid($v,$p)
513 if {$p ne [lindex $varcstart($v) $pa]} {
514 splitvarc $p $v
515 set pa $varcid($v,$p)
516 }
518 - # seeds always need to be renumbered (and taken out of the seeds list)
519 - if {[lindex $vupptr($v) $pa] == 0} {
520 - set i [lsearch -exact $vseeds($v) $p]
521 - if {$i >= 0} {
522 - set vseeds($v) [lreplace $vseeds($v) $i $i]
523 - } else {
524 - puts "oops couldn't find [shortids $p] in seeds"
525 - }
526 - renumbervarc $pa $v
527 - } elseif {[string compare [lindex $varctok($v) $a] \
528 - [lindex $varctok($v) $pa]] > 0} {
517 + # seeds always need to be renumbered
518 + if {[lindex $vupptr($v) $pa] == 0 ||
519 + [string compare [lindex $varctok($v) $a] \
520 + [lindex $varctok($v) $pa]] > 0} {
521 renumbervarc $pa $v
522 }
523 }
@@ -556,7 +548,7 @@ proc insertrow {id p v} {
548
549 proc removerow {id v} {
550 global varcid varccommits parents children commitidx
559 - global varctok vtokmod
551 + global varctok vtokmod cmitlisted
552
553 if {[llength $parents($v,$id)] != 1} {
554 puts "oops: removerow [shortids $id] has [llength $parents($v,$id)] parents"
@@ -579,7 +571,6 @@ proc removerow {id v} {
571 if {$j >= 0} {
572 set children($v,$p) [lreplace $children($v,$p) $j $j]
573 }
582 - set tok [lindex $varctok($v) $a]
574 if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
575 modify_arc $v $a $i
576 }
@@ -595,6 +586,7 @@ proc vtokcmp {v a b} {
586
587 proc modify_arc {v a {lim {}}} {
588 global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
589 + global vhighlights nhighlights fhighlights rhighlights
590
591 set vtokmod($v) [lindex $varctok($v) $a]
592 set varcmod($v) $a
@@ -613,15 +605,18 @@ proc modify_arc {v a {lim {}}} {
605 set vrowmod($v) $r
606 undolayout $r
607 }
608 + catch {unset nhighlights}
609 + catch {unset fhighlights}
610 + catch {unset vhighlights}
611 + catch {unset rhighlights}
612 }
613
614 proc update_arcrows {v} {
615 global vtokmod varcmod vrowmod varcrow commitidx currentid selectedline
620 - global varcid vseeds vrownum varcorder varcix varccommits
616 + global varcid vrownum varcorder varcix varccommits
617 global vupptr vdownptr vleftptr varctok
622 - global uat displayorder parentlist curview cached_commitrow
618 + global displayorder parentlist curview cached_commitrow
619
624 - set t1 [clock clicks -milliseconds]
620 set narctot [expr {[llength $varctok($v)] - 1}]
621 set a $varcmod($v)
622 while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
@@ -684,8 +679,6 @@ proc update_arcrows {v} {
679 if {[info exists currentid]} {
680 set selectedline [rowofcommit $currentid]
681 }
687 - set t2 [clock clicks -milliseconds]
688 - incr uat [expr {$t2-$t1}]
682 }
683
684 # Test whether view $v contains commit $id
@@ -837,7 +830,7 @@ proc closevarcs {v} {
830 }
831
832 proc getcommitlines {fd inst view} {
840 - global cmitlisted commitinterest leftover getdbg
833 + global cmitlisted commitinterest leftover
834 global commitidx commitdata
835 global parents children curview hlview
836 global vnextroot idpending ordertok
@@ -1051,8 +1044,6 @@ proc chewcommits {view} {
1044 if {$commitidx($curview) > 0} {
1045 #set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
1046 #puts "overall $ms ms for $numcommits commits"
1054 - #global uat
1055 - #puts "${uat}ms in update_arcrows"
1047 } else {
1048 show_status "No commits selected"
1049 }
@@ -3506,19 +3497,23 @@ proc readdiffindex {fd serial} {
3497 # we only need to see one line and we don't really care what it says...
3498 close $fd
3499
3509 - # now see if there are any local changes not checked in to the index
3510 - if {$serial == $lserial} {
3511 - set fd [open "|git diff-files" r]
3512 - fconfigure $fd -blocking 0
3513 - filerun $fd [list readdifffiles $fd $serial]
3500 + if {$serial != $lserial} {
3501 + return 0
3502 }
3503
3516 - if {$isdiff && $serial == $lserial && ![commitinview $nullid2 $curview]} {
3504 + # now see if there are any local changes not checked in to the index
3505 + set fd [open "|git diff-files" r]
3506 + fconfigure $fd -blocking 0
3507 + filerun $fd [list readdifffiles $fd $serial]
3508 +
3509 + if {$isdiff && ![commitinview $nullid2 $curview]} {
3510 # add the line for the changes in the index to the graph
3511 set hl "Local changes checked in to index but not committed"
3512 set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"]
3513 set commitdata($nullid2) "\n $hl\n"
3514 insertrow $nullid2 $mainheadid $curview
3515 + } elseif {!$isdiff && [commitinview $nullid2 $curview]} {
3516 + removerow $nullid2 $curview
3517 }
3518 return 0
3519 }
@@ -3537,7 +3532,11 @@ proc readdifffiles {fd serial} {
3532 # we only need to see one line and we don't really care what it says...
3533 close $fd
3534
3540 - if {$isdiff && $serial == $lserial && ![commitinview $nullid $curview]} {
3535 + if {$serial != $lserial} {
3536 + return 0
3537 + }
3538 +
3539 + if {$isdiff && ![commitinview $nullid $curview]} {
3540 # add the line for the local diff to the graph
3541 set hl "Local uncommitted changes, not checked in to index"
3542 set commitinfo($nullid) [list $hl {} {} {} {} " $hl\n"]
@@ -3548,6 +3547,8 @@ proc readdifffiles {fd serial} {
3547 set p $mainheadid
3548 }
3549 insertrow $nullid $p $curview
3550 + } elseif {!$isdiff && [commitinview $nullid $curview]} {
3551 + removerow $nullid $curview
3552 }
3553 return 0
3554 }
@@ -9191,7 +9192,6 @@ set viewperm(0) 0
9192 set viewargs(0) {}
9193
9194 set loginstance 0
9194 -set getdbg 0
9195 set cmdlineok 0
9196 set stopped 0
9197 set stuffsaved 0