X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=gitk-git%2Fgitk;h=d093a39506798c750cc838f0085f6721e0f733a9;hb=847d10f56d7853cd0e139a7c2e6ad0ad2de5c464;hp=9ab6dbaa460cc4c63398e836506c204d382419b4;hpb=1fe82d609f9a6ec146fa39880a04e11eb5275810;p=git.git diff --git a/gitk-git/gitk b/gitk-git/gitk index 9ab6dbaa4..d093a3950 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -90,6 +90,15 @@ proc dorunq {} { } } +proc reg_instance {fd} { + global commfd leftover loginstance + + set i [incr loginstance] + set commfd($i) $fd + set leftover($i) {} + return $i +} + proc unmerged_files {files} { global nr_unmerged @@ -294,11 +303,11 @@ proc parseviewrevs {view revs} { # Start off a git log process and arrange to read its output proc start_rev_list {view} { global startmsecs commitidx viewcomplete curview - global commfd leftover tclencoding + global tclencoding global viewargs viewargscmd viewfiles vfilelimit - global showlocalchanges commitinterest mainheadid - global viewactive loginstance viewinstances vmergeonly - global pending_select mainheadid + global showlocalchanges commitinterest + global viewactive viewinstances vmergeonly + global mainheadid global vcanopt vflags vrevs vorigargs set startmsecs [clock clicks -milliseconds] @@ -354,11 +363,9 @@ proc start_rev_list {view} { error_popup "[mc "Error executing git log:"] $err" return 0 } - set i [incr loginstance] + set i [reg_instance $fd] set viewinstances($view) [list $i] - set commfd($i) $fd - set leftover($i) {} - if {$showlocalchanges} { + if {$showlocalchanges && $mainheadid ne {}} { lappend commitinterest($mainheadid) {dodiffindex} } fconfigure $fd -blocking 0 -translation lf -eofchar {} @@ -367,36 +374,63 @@ proc start_rev_list {view} { } filerun $fd [list getcommitlines $fd $i $view 0] nowbusy $view [mc "Reading"] - if {$view == $curview} { - set pending_select $mainheadid - } set viewcomplete($view) 0 set viewactive($view) 1 return 1 } -proc stop_rev_list {view} { - global commfd viewinstances leftover +proc stop_instance {inst} { + global commfd leftover - foreach inst $viewinstances($view) { - set fd $commfd($inst) - catch { - set pid [pid $fd] + set fd $commfd($inst) + catch { + set pid [pid $fd] + + if {$::tcl_platform(platform) eq {windows}} { + exec kill -f $pid + } else { exec kill $pid } - catch {close $fd} - nukefile $fd - unset commfd($inst) - unset leftover($inst) + } + catch {close $fd} + nukefile $fd + unset commfd($inst) + unset leftover($inst) +} + +proc stop_backends {} { + global commfd + + foreach inst [array names commfd] { + stop_instance $inst + } +} + +proc stop_rev_list {view} { + global viewinstances + + foreach inst $viewinstances($view) { + stop_instance $inst } set viewinstances($view) {} } -proc getcommits {} { +proc reset_pending_select {selid} { + global pending_select mainheadid + + if {$selid ne {}} { + set pending_select $selid + } else { + set pending_select $mainheadid + } +} + +proc getcommits {selid} { global canv curview need_redisplay viewactive initlayout if {[start_rev_list $curview]} { + reset_pending_select $selid show_status [mc "Reading commits..."] set need_redisplay 1 } else { @@ -406,8 +440,8 @@ proc getcommits {} { proc updatecommits {} { global curview vcanopt vorigargs vfilelimit viewinstances - global viewactive viewcomplete loginstance tclencoding mainheadid - global startmsecs commfd showneartags showlocalchanges leftover + global viewactive viewcomplete tclencoding + global startmsecs showneartags showlocalchanges global mainheadid pending_select global isworktree global varcid vposids vnegids vflags vrevs @@ -468,10 +502,8 @@ proc updatecommits {} { if {$viewactive($view) == 0} { set startmsecs [clock clicks -milliseconds] } - set i [incr loginstance] + set i [reg_instance $fd] lappend viewinstances($view) $i - set commfd($i) $fd - set leftover($i) {} fconfigure $fd -blocking 0 -translation lf -eofchar {} if {$tclencoding != {}} { fconfigure $fd -encoding $tclencoding @@ -479,7 +511,7 @@ proc updatecommits {} { filerun $fd [list getcommitlines $fd $i $view 1] incr viewactive($view) set viewcomplete($view) 0 - set pending_select $mainheadid + reset_pending_select {} nowbusy $view "Reading" if {$showneartags} { getallcommits @@ -491,11 +523,16 @@ proc reloadcommits {} { global showneartags treediffs commitinterest cached_commitrow global targetid + set selid {} + if {$selectedline ne {}} { + set selid $currentid + } + if {!$viewcomplete($curview)} { stop_rev_list $curview } resetvarcs $curview - catch {unset selectedline} + set selectedline {} catch {unset currentid} catch {unset thickerline} catch {unset treediffs} @@ -509,7 +546,7 @@ proc reloadcommits {} { catch {unset cached_commitrow} catch {unset targetid} setcanvscroll - getcommits + getcommits $selid return 0 } @@ -927,7 +964,7 @@ proc removefakerow {id} { modify_arc $v $a $i if {[info exist currentid] && $id eq $currentid} { unset currentid - unset selectedline + set selectedline {} } if {[info exists targetid] && $targetid eq $id} { set targetid $p @@ -1467,11 +1504,17 @@ proc chewcommits {} { if {$viewcomplete($curview)} { global commitidx varctok global numcommits startmsecs - global mainheadid nullid if {[info exists pending_select]} { - set row [first_real_row] - selectline $row 1 + update + reset_pending_select {} + + if {[commitinview $pending_select $curview]} { + selectline [rowofcommit $pending_select] 1 + } else { + set row [first_real_row] + selectline $row 1 + } } if {$commitidx($curview) > 0} { #set ms [expr {[clock clicks -milliseconds] - $startmsecs}] @@ -1604,12 +1647,10 @@ proc readrefs {} { set mainhead {} set mainheadid {} catch { + set mainheadid [exec git rev-parse HEAD] set thehead [exec git symbolic-ref HEAD] if {[string match "refs/heads/*" $thehead]} { set mainhead [string range $thehead 11 end] - if {[info exists headids($mainhead)]} { - set mainheadid $headids($mainhead) - } } } } @@ -1838,7 +1879,7 @@ proc makewindow {} { pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \ -side left global selectedline - trace add variable selectedline {write unset} selectedline_change + trace add variable selectedline write selectedline_change # Status label and progress bar set statusw .tf.bar.status @@ -2106,6 +2147,7 @@ proc makewindow {} { bind . <$M1B-minus> {incrfont -1} bind . <$M1B-KP_Subtract> {incrfont -1} wm protocol . WM_DELETE_WINDOW doquit + bind . {stop_backends} bind . "click %W" bind $fstring {dofind 1 1} bind $sha1entry gotocommit @@ -2185,7 +2227,7 @@ proc windows_mousewheel_redirector {W X Y D} { proc selectedline_change {n1 n2 op} { global selectedline rownumsel - if {$op eq "unset"} { + if {$selectedline eq {}} { set rownumsel {} } else { set rownumsel [expr {$selectedline + 1}] @@ -3274,7 +3316,7 @@ proc showview {n} { set ytop [expr {[lindex $span 0] * $ymax}] set ybot [expr {[lindex $span 1] * $ymax}] set yscreen [expr {($ybot - $ytop) / 2}] - if {[info exists selectedline]} { + if {$selectedline ne {}} { set selid $currentid set y [yc $selectedline] if {$ytop < $y && $y < $ybot} { @@ -3303,10 +3345,7 @@ proc showview {n} { run refill_reflist if {![info exists viewcomplete($n)]} { - if {$selid ne {}} { - set pending_select $selid - } - getcommits + getcommits $selid return } @@ -3340,18 +3379,18 @@ proc showview {n} { drawvisible if {$row ne {}} { selectline $row 0 - } elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} { - selectline [rowofcommit $mainheadid] 1 } elseif {!$viewcomplete($n)} { - if {$selid ne {}} { - set pending_select $selid - } else { - set pending_select $mainheadid - } + reset_pending_select $selid } else { - set row [first_real_row] - if {$row < $numcommits} { - selectline $row 0 + reset_pending_select {} + + if {[commitinview $pending_select $curview]} { + selectline [rowofcommit $pending_select] 1 + } else { + set row [first_real_row] + if {$row < $numcommits} { + selectline $row 0 + } } } if {!$viewcomplete($n)} { @@ -3388,7 +3427,7 @@ proc bolden {row font} { lappend boldrows $row $canv itemconf $linehtag($row) -font $font - if {[info exists selectedline] && $row == $selectedline} { + if {$row == $selectedline} { $canv delete secsel set t [eval $canv create rect [$canv bbox $linehtag($row)] \ -outline {{}} -tags secsel \ @@ -3402,7 +3441,7 @@ proc bolden_name {row font} { lappend boldnamerows $row $canv2 itemconf $linentag($row) -font $font - if {[info exists selectedline] && $row == $selectedline} { + if {$row == $selectedline} { $canv2 delete secsel set t [eval $canv2 create rect [$canv2 bbox $linentag($row)] \ -outline {{}} -tags secsel \ @@ -3831,7 +3870,7 @@ proc askrelhighlight {row id} { global descendent highlight_related iddrawn rhighlights global selectedline ancestor - if {![info exists selectedline]} return + if {$selectedline eq {}} return set isbold 0 if {$highlight_related eq [mc "Descendant"] || $highlight_related eq [mc "Not descendant"]} { @@ -4005,7 +4044,7 @@ proc visiblerows {} { proc layoutmore {} { global commitidx viewcomplete curview - global numcommits pending_select selectedline curview + global numcommits pending_select curview global lastscrollset lastscrollrows commitinterest if {$lastscrollrows < 100 || $viewcomplete($curview) || @@ -4014,6 +4053,7 @@ proc layoutmore {} { } if {[info exists pending_select] && [commitinview $pending_select $curview]} { + update selectline [rowofcommit $pending_select] 1 } drawvisible @@ -4022,6 +4062,7 @@ proc layoutmore {} { proc doshowlocalchanges {} { global curview mainheadid + if {$mainheadid eq {}} return if {[commitinview $mainheadid $curview]} { dodiffindex } else { @@ -4050,10 +4091,11 @@ proc dodiffindex {} { incr lserial set fd [open "|git diff-index --cached HEAD" r] fconfigure $fd -blocking 0 - filerun $fd [list readdiffindex $fd $lserial] + set i [reg_instance $fd] + filerun $fd [list readdiffindex $fd $lserial $i] } -proc readdiffindex {fd serial} { +proc readdiffindex {fd serial inst} { global mainheadid nullid nullid2 curview commitinfo commitdata lserial set isdiff 1 @@ -4064,7 +4106,7 @@ proc readdiffindex {fd serial} { set isdiff 0 } # we only need to see one line and we don't really care what it says... - close $fd + stop_instance $inst if {$serial != $lserial} { return 0 @@ -4073,7 +4115,8 @@ proc readdiffindex {fd serial} { # now see if there are any local changes not checked in to the index set fd [open "|git diff-files" r] fconfigure $fd -blocking 0 - filerun $fd [list readdifffiles $fd $serial] + set i [reg_instance $fd] + filerun $fd [list readdifffiles $fd $serial $i] if {$isdiff && ![commitinview $nullid2 $curview]} { # add the line for the changes in the index to the graph @@ -4090,7 +4133,7 @@ proc readdiffindex {fd serial} { return 0 } -proc readdifffiles {fd serial} { +proc readdifffiles {fd serial inst} { global mainheadid nullid nullid2 curview global commitinfo commitdata lserial @@ -4102,7 +4145,7 @@ proc readdifffiles {fd serial} { set isdiff 0 } # we only need to see one line and we don't really care what it says... - close $fd + stop_instance $inst if {$serial != $lserial} { return 0 @@ -4841,7 +4884,8 @@ proc drawcmittext {id row col} { global cmitlisted commitinfo rowidlist parentlist global rowtextx idpos idtags idheads idotherrefs global linehtag linentag linedtag selectedline - global canvxmax boldrows boldnamerows fgcolor nullid nullid2 + global canvxmax boldrows boldnamerows fgcolor + global mainheadid nullid nullid2 circleitem circlecolors # listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right set listed $cmitlisted($curview,$id) @@ -4849,8 +4893,10 @@ proc drawcmittext {id row col} { set ofill red } elseif {$id eq $nullid2} { set ofill green + } elseif {$id eq $mainheadid} { + set ofill yellow } else { - set ofill [expr {$listed != 0 ? $listed == 2 ? "gray" : "blue" : "white"}] + set ofill [lindex $circlecolors $listed] } set x [xc $row $col] set y [yc $row] @@ -4874,6 +4920,7 @@ proc drawcmittext {id row col} { [expr {$x - $orad}] [expr {$y + $orad - 1}] \ -fill $ofill -outline $fgcolor -width 1 -tags circle] } + set circleitem($row) $t $canv raise $t $canv bind $t <1> {selcanvline {} %x %y} set rmx [llength [lindex $rowidlist $row]] @@ -4916,7 +4963,7 @@ proc drawcmittext {id row col} { -text $name -font $nfont -tags text] set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \ -text $date -font mainfont -tags text] - if {[info exists selectedline] && $selectedline == $row} { + if {$selectedline == $row} { make_secsel $row } set xr [expr {$xt + [font measure $font $headline]}] @@ -5107,7 +5154,7 @@ proc drawvisible {} { if {$endrow >= $vrowmod($curview)} { update_arcrows $curview } - if {[info exists selectedline] && + if {$selectedline ne {} && $row <= $selectedline && $selectedline <= $endrow} { set targetrow $selectedline } elseif {[info exists targetid]} { @@ -5125,10 +5172,16 @@ proc drawvisible {} { proc clear_display {} { global iddrawn linesegs need_redisplay nrows_drawn global vhighlights fhighlights nhighlights rhighlights + global linehtag linentag linedtag boldrows boldnamerows allcanvs delete all catch {unset iddrawn} catch {unset linesegs} + catch {unset linehtag} + catch {unset linentag} + catch {unset linedtag} + set boldrows {} + set boldnamerows {} catch {unset vhighlights} catch {unset fhighlights} catch {unset nhighlights} @@ -5423,7 +5476,7 @@ proc dofind {{dirn 1} {wrap 1}} { } focus . if {$findstring eq {} || $numcommits == 0} return - if {![info exists selectedline]} { + if {$selectedline eq {}} { set findstartline [lindex [visiblerows] [expr {$dirn < 0}]] } else { set findstartline $selectedline @@ -5619,7 +5672,7 @@ proc markmatches {canv l str tag matches font row} { [expr {$x0+$xlen+2}] $y1 \ -outline {} -tags [list match$l matches] -fill yellow] $canv lower $t - if {[info exists selectedline] && $row == $selectedline} { + if {$row == $selectedline} { $canv raise $t secsel } } @@ -5778,7 +5831,7 @@ proc appendrefs {pos ids var} { proc dispneartags {delay} { global selectedline currentid showneartags tagphase - if {![info exists selectedline] || !$showneartags} return + if {$selectedline eq {} || !$showneartags} return after cancel dispnexttag if {$delay} { after 200 dispnexttag @@ -5792,7 +5845,7 @@ proc dispneartags {delay} { proc dispnexttag {} { global selectedline currentid showneartags tagphase ctext - if {![info exists selectedline] || !$showneartags} return + if {$selectedline eq {} || !$showneartags} return switch -- $tagphase { 0 { set dtags [desctags $currentid] @@ -6014,7 +6067,7 @@ proc sellastline {} { proc selnextline {dir} { global selectedline focus . - if {![info exists selectedline]} return + if {$selectedline eq {}} return set l [expr {$selectedline + $dir}] unmarkmatches selectline $l 1 @@ -6029,7 +6082,7 @@ proc selnextpage {dir} { } allcanvs yview scroll [expr {$dir * $lpp}] units drawvisible - if {![info exists selectedline]} return + if {$selectedline eq {}} return set l [expr {$selectedline + $dir * $lpp}] if {$l < 0} { set l 0 @@ -6043,7 +6096,7 @@ proc selnextpage {dir} { proc unselectline {} { global selectedline currentid - catch {unset selectedline} + set selectedline {} catch {unset currentid} allcanvs delete secsel rhighlight_none @@ -6052,7 +6105,7 @@ proc unselectline {} { proc reselectline {} { global selectedline - if {[info exists selectedline]} { + if {$selectedline ne {}} { selectline $selectedline 0 } } @@ -6422,9 +6475,10 @@ proc diffcmd {ids flags} { proc gettreediffs {ids} { global treediff treepending + if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return + set treepending $ids set treediff {} - if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return fconfigure $gdtf -blocking 0 filerun $gdtf [list gettreediffline $gdtf $ids] } @@ -6864,7 +6918,7 @@ proc redisplay {} { setcanvscroll allcanvs yview moveto [lindex $span 0] drawvisible - if {[info exists selectedline]} { + if {$selectedline ne {}} { selectline $selectedline 0 allcanvs yview moveto [lindex $span 0] } @@ -7185,8 +7239,7 @@ proc rowmenu {x y id} { stopfinding set rowmenuid $id - if {![info exists selectedline] - || [rowofcommit $id] eq $selectedline} { + if {$selectedline eq {} || [rowofcommit $id] eq $selectedline} { set state disabled } else { set state normal @@ -7210,7 +7263,7 @@ proc rowmenu {x y id} { proc diffvssel {dirn} { global rowmenuid selectedline - if {![info exists selectedline]} return + if {$selectedline eq {}} return if {$dirn} { set oldid [commitonrow $selectedline] set newid $rowmenuid @@ -7394,12 +7447,18 @@ proc domktag {} { } proc redrawtags {id} { - global canv linehtag idpos currentid curview - global canvxmax iddrawn + global canv linehtag idpos currentid curview cmitlisted + global canvxmax iddrawn circleitem mainheadid circlecolors if {![commitinview $id $curview]} return if {![info exists iddrawn($id)]} return set row [rowofcommit $id] + if {$id eq $mainheadid} { + set ofill yellow + } else { + set ofill [lindex $circlecolors $cmitlisted($curview,$id)] + } + $canv itemconf $circleitem($row) -fill $ofill $canv delete tag.$id set xt [eval drawtags $id $idpos($id)] $canv coords $linehtag($row) $xt [lindex $idpos($id) 2] @@ -7569,8 +7628,8 @@ proc cherrypick {} { if {$mainhead ne {}} { movehead $newhead $mainhead movedhead $newhead $mainhead - set mainheadid $newhead } + set mainheadid $newhead redrawtags $oldhead redrawtags $newhead selbyid $newhead @@ -7670,7 +7729,7 @@ proc headmenu {x y id head} { } proc cobranch {} { - global headmenuid headmenuhead mainhead headids + global headmenuid headmenuhead headids global showlocalchanges mainheadid # check the tree is clean first?? @@ -7706,12 +7765,10 @@ proc readcheckoutstat {fd newhead newheadid} { if {[catch {close $fd} err]} { error_popup $err } - set oldmainhead $mainhead + set oldmainid $mainheadid set mainhead $newhead set mainheadid $newheadid - if {[info exists headids($oldmainhead)]} { - redrawtags $headids($oldmainhead) - } + redrawtags $oldmainid redrawtags $newheadid selbyid $newheadid if {$showlocalchanges} { @@ -9011,12 +9068,14 @@ proc rereadrefs {} { [array names idheads] [array names idotherrefs]]] foreach id $refids { set v [listrefs $id] - if {![info exists ref($id)] || $ref($id) != $v || - ($id eq $oldmainhead && $id ne $mainheadid) || - ($id eq $mainheadid && $id ne $oldmainhead)} { + if {![info exists ref($id)] || $ref($id) != $v} { redrawtags $id } } + if {$oldmainhead ne $mainheadid} { + redrawtags $oldmainhead + redrawtags $mainheadid + } run refill_reflist } @@ -9756,6 +9815,8 @@ set diffcontext 3 set ignorespace 0 set selectbgcolor gray85 +set circlecolors {white blue gray blue blue} + ## For msgcat loading, first locate the installation location. if { [info exists ::env(GITK_MSGSDIR)] } { ## Msgsdir was manually set in the environment. @@ -9886,6 +9947,7 @@ set viewperm(0) 0 set viewargs(0) {} set viewargscmd(0) {} +set selectedline {} set numcommits 0 set loginstance 0 set cmdlineok 0 @@ -9929,4 +9991,4 @@ if {[info exists permviews]} { addviewmenu $n } } -getcommits +getcommits {}