From: Paul Mackerras Date: Wed, 26 Dec 2007 12:03:43 +0000 (+1100) Subject: gitk: Fix another collection of bugs X-Git-Tag: v1.5.6-rc0~20^2~36 X-Git-Url: https://git.tokkee.org/?p=git.git;a=commitdiff_plain;h=fc2a256f4a49732226b742762b628af6a8bd05d8 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 --- diff --git a/gitk b/gitk index 86dd575ca..b5c9e7a1b 100755 --- a/gitk +++ b/gitk @@ -174,6 +174,7 @@ proc updatecommits {} { if {$showlocalchanges && [commitinview $mainheadid $curview]} { dodiffindex } + rereadrefs set view $curview set commits [exec git rev-parse --default HEAD --revs-only \ $viewargs($view)] @@ -218,8 +219,6 @@ proc updatecommits {} { incr viewactive($view) set viewcomplete($view) 0 nowbusy $view "Reading" - readrefs - changedrefs if {$showneartags} { getallcommits } @@ -579,7 +578,7 @@ proc insertrow {id p v} { proc removerow {id v} { global varcid varccommits parents children commitidx - global varctok vtokmod cmitlisted + global varctok vtokmod cmitlisted currentid selectedline if {[llength $parents($v,$id)] != 1} { puts "oops: removerow [shortids $id] has [llength $parents($v,$id)] parents" @@ -605,6 +604,10 @@ proc removerow {id v} { if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} { modify_arc $v $a $i } + if {[info exist currentid] && $id eq $currentid} { + unset currentid + unset selectedline + } drawvisible } @@ -733,7 +736,7 @@ proc rowofcommit {id} { return {} } set a $varcid($v,$id) - if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] > 0} { + if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] >= 0} { update_arcrows $v } set i [lsearch -exact $varccommits($v,$a) $id] @@ -3515,7 +3518,7 @@ proc dodiffindex {} { } proc readdiffindex {fd serial} { - global mainheadid nullid2 curview commitinfo commitdata lserial + global mainheadid nullid nullid2 curview commitinfo commitdata lserial set isdiff 1 if {[gets $fd line] < 0} { @@ -3541,6 +3544,9 @@ proc readdiffindex {fd serial} { set hl [mc "Local changes checked in to index but not committed"] set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"] set commitdata($nullid2) "\n $hl\n" + if {[commitinview $nullid $curview]} { + removerow $nullid $curview + } insertrow $nullid2 $mainheadid $curview } elseif {!$isdiff && [commitinview $nullid2 $curview]} { removerow $nullid2 $curview @@ -5058,7 +5064,9 @@ proc selcanvline {w x y} { set l 0 } if {$w eq $canv} { - if {![info exists rowtextx($l)] || $x < $rowtextx($l)} return + set xmax [lindex [$canv cget -scrollregion] 2] + set xleft [expr {[lindex [$canv xview] 0] * $xmax}] + if {![info exists rowtextx($l)] || $xleft + $x < $rowtextx($l)} return } unmarkmatches selectline $l 1 @@ -5305,13 +5313,12 @@ proc selectline {l isnew} { make_secsel $l + set id [commitonrow $l] if {$isnew} { - addtohistory [list selectline $l 0] + addtohistory [list selbyid $id] } set selectedline $l - - set id [commitonrow $l] set currentid $id $sha1entry delete 0 end $sha1entry insert 0 $id @@ -6765,24 +6772,24 @@ proc domktag {} { } proc redrawtags {id} { - global canv linehtag idpos selectedline curview + global canv linehtag idpos currentid curview global canvxmax iddrawn if {![commitinview $id $curview]} return if {![info exists iddrawn($id)]} return - drawcommits [rowofcommit $id] + set row [rowofcommit $id] $canv delete tag.$id set xt [eval drawtags $id $idpos($id)] - $canv coords $linehtag([rowofcommit $id]) $xt [lindex $idpos($id) 2] - set text [$canv itemcget $linehtag([rowofcommit $id]) -text] - set xr [expr {$xt + [font measure mainfont $text]}] + $canv coords $linehtag($row) $xt [lindex $idpos($id) 2] + set text [$canv itemcget $linehtag($row) -text] + set font [$canv itemcget $linehtag($row) -font] + set xr [expr {$xt + [font measure $font $text]}] if {$xr > $canvxmax} { set canvxmax $xr setcanvscroll } - if {[info exists selectedline] - && $selectedline == [rowofcommit $id]} { - selectline $selectedline 0 + if {[info exists currentid] && $currentid == $id} { + make_secsel $row } } @@ -8342,7 +8349,7 @@ proc changedrefs {} { } proc rereadrefs {} { - global idtags idheads idotherrefs mainhead + global idtags idheads idotherrefs mainheadid set refids [concat [array names idtags] \ [array names idheads] [array names idotherrefs]] @@ -8351,7 +8358,7 @@ proc rereadrefs {} { set ref($id) [listrefs $id] } } - set oldmainhead $mainhead + set oldmainhead $mainheadid readrefs changedrefs set refids [lsort -unique [concat $refids [array names idtags] \ @@ -8359,8 +8366,8 @@ proc rereadrefs {} { foreach id $refids { set v [listrefs $id] if {![info exists ref($id)] || $ref($id) != $v || - ($id eq $oldmainhead && $id ne $mainhead) || - ($id eq $mainhead && $id ne $oldmainhead)} { + ($id eq $oldmainhead && $id ne $mainheadid) || + ($id eq $mainheadid && $id ne $oldmainhead)} { redrawtags $id } }