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

gitk: Fix another collection of bugs

* Fixed a bug that occasionally resulted in Tcl "can't use empty string as argument to incr" errors - rowofcommit was sometimes not calling update_arcrows when it needed to. * Fixed a "no such element in array" error when removing a fake row, by unsetting currentid and selectedline in removerow if the row we are removing is the currently selected row. * Made the "update commits" function always do "reread references". * Made dodiffindex et al. remove the fake row(s) if necessary. * Fixed a bug where clicking on a row in the graph display pane didn't account for horizontal scrolling of the pane. * Started changing things that cached information based on row numbers to use commit IDs instead -- this converts the "select line" items that are put into the history list to use "select by ID" instead. * Simplified redrawtags a bit, and fixed a bug where it would use the mainfont for working out how far it extends to the right in the graph display pane rather than the actual font (which might be bold). * Fixed a bug where "reread references" wouldn't notice if the currently checked-out head had changed. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Dec 26, 2007 at 23:03 UTC fc2a256f4a49732226b742762b628af6a8bd05d8
1 file changed +28 -21
gitk
+28 -21
@@ -174,6 +174,7 @@ proc updatecommits {} {
174 if {$showlocalchanges && [commitinview $mainheadid $curview]} {
175 dodiffindex
176 }
177 + rereadrefs
178 set view $curview
179 set commits [exec git rev-parse --default HEAD --revs-only \
180 $viewargs($view)]
@@ -218,8 +219,6 @@ proc updatecommits {} {
219 incr viewactive($view)
220 set viewcomplete($view) 0
221 nowbusy $view "Reading"
221 - readrefs
222 - changedrefs
222 if {$showneartags} {
223 getallcommits
224 }
@@ -579,7 +578,7 @@ proc insertrow {id p v} {
578
579 proc removerow {id v} {
580 global varcid varccommits parents children commitidx
582 - global varctok vtokmod cmitlisted
581 + global varctok vtokmod cmitlisted currentid selectedline
582
583 if {[llength $parents($v,$id)] != 1} {
584 puts "oops: removerow [shortids $id] has [llength $parents($v,$id)] parents"
@@ -605,6 +604,10 @@ proc removerow {id v} {
604 if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
605 modify_arc $v $a $i
606 }
607 + if {[info exist currentid] && $id eq $currentid} {
608 + unset currentid
609 + unset selectedline
610 + }
611 drawvisible
612 }
613
@@ -733,7 +736,7 @@ proc rowofcommit {id} {
736 return {}
737 }
738 set a $varcid($v,$id)
736 - if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] > 0} {
739 + if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] >= 0} {
740 update_arcrows $v
741 }
742 set i [lsearch -exact $varccommits($v,$a) $id]
@@ -3515,7 +3518,7 @@ proc dodiffindex {} {
3518 }
3519
3520 proc readdiffindex {fd serial} {
3518 - global mainheadid nullid2 curview commitinfo commitdata lserial
3521 + global mainheadid nullid nullid2 curview commitinfo commitdata lserial
3522
3523 set isdiff 1
3524 if {[gets $fd line] < 0} {
@@ -3541,6 +3544,9 @@ proc readdiffindex {fd serial} {
3544 set hl [mc "Local changes checked in to index but not committed"]
3545 set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"]
3546 set commitdata($nullid2) "\n $hl\n"
3547 + if {[commitinview $nullid $curview]} {
3548 + removerow $nullid $curview
3549 + }
3550 insertrow $nullid2 $mainheadid $curview
3551 } elseif {!$isdiff && [commitinview $nullid2 $curview]} {
3552 removerow $nullid2 $curview
@@ -5058,7 +5064,9 @@ proc selcanvline {w x y} {
5064 set l 0
5065 }
5066 if {$w eq $canv} {
5061 - if {![info exists rowtextx($l)] || $x < $rowtextx($l)} return
5067 + set xmax [lindex [$canv cget -scrollregion] 2]
5068 + set xleft [expr {[lindex [$canv xview] 0] * $xmax}]
5069 + if {![info exists rowtextx($l)] || $xleft + $x < $rowtextx($l)} return
5070 }
5071 unmarkmatches
5072 selectline $l 1
@@ -5305,13 +5313,12 @@ proc selectline {l isnew} {
5313
5314 make_secsel $l
5315
5316 + set id [commitonrow $l]
5317 if {$isnew} {
5309 - addtohistory [list selectline $l 0]
5318 + addtohistory [list selbyid $id]
5319 }
5320
5321 set selectedline $l
5313 -
5314 - set id [commitonrow $l]
5322 set currentid $id
5323 $sha1entry delete 0 end
5324 $sha1entry insert 0 $id
@@ -6765,24 +6772,24 @@ proc domktag {} {
6772 }
6773
6774 proc redrawtags {id} {
6768 - global canv linehtag idpos selectedline curview
6775 + global canv linehtag idpos currentid curview
6776 global canvxmax iddrawn
6777
6778 if {![commitinview $id $curview]} return
6779 if {![info exists iddrawn($id)]} return
6773 - drawcommits [rowofcommit $id]
6780 + set row [rowofcommit $id]
6781 $canv delete tag.$id
6782 set xt [eval drawtags $id $idpos($id)]
6776 - $canv coords $linehtag([rowofcommit $id]) $xt [lindex $idpos($id) 2]
6777 - set text [$canv itemcget $linehtag([rowofcommit $id]) -text]
6778 - set xr [expr {$xt + [font measure mainfont $text]}]
6783 + $canv coords $linehtag($row) $xt [lindex $idpos($id) 2]
6784 + set text [$canv itemcget $linehtag($row) -text]
6785 + set font [$canv itemcget $linehtag($row) -font]
6786 + set xr [expr {$xt + [font measure $font $text]}]
6787 if {$xr > $canvxmax} {
6788 set canvxmax $xr
6789 setcanvscroll
6790 }
6783 - if {[info exists selectedline]
6784 - && $selectedline == [rowofcommit $id]} {
6785 - selectline $selectedline 0
6791 + if {[info exists currentid] && $currentid == $id} {
6792 + make_secsel $row
6793 }
6794 }
6795
@@ -8342,7 +8349,7 @@ proc changedrefs {} {
8349 }
8350
8351 proc rereadrefs {} {
8345 - global idtags idheads idotherrefs mainhead
8352 + global idtags idheads idotherrefs mainheadid
8353
8354 set refids [concat [array names idtags] \
8355 [array names idheads] [array names idotherrefs]]
@@ -8351,7 +8358,7 @@ proc rereadrefs {} {
8358 set ref($id) [listrefs $id]
8359 }
8360 }
8354 - set oldmainhead $mainhead
8361 + set oldmainhead $mainheadid
8362 readrefs
8363 changedrefs
8364 set refids [lsort -unique [concat $refids [array names idtags] \
@@ -8359,8 +8366,8 @@ proc rereadrefs {} {
8366 foreach id $refids {
8367 set v [listrefs $id]
8368 if {![info exists ref($id)] || $ref($id) != $v ||
8362 - ($id eq $oldmainhead && $id ne $mainhead) ||
8363 - ($id eq $mainhead && $id ne $oldmainhead)} {
8369 + ($id eq $oldmainhead && $id ne $mainheadid) ||
8370 + ($id eq $mainheadid && $id ne $oldmainhead)} {
8371 redrawtags $id
8372 }
8373 }