@matheusbsbs / matheus-bagliano / commits / 3e76608d39
Fork 0

gitk: Select head of current branch by default

Instead of selecting the first commit that appears, this makes gitk select the currently checked out head, if the user hasn't explicitly selected some other commit by the time it appears. If the head hasn't appeared by the time the graph is complete, then we select the first real commit. This applies both for graph updates and when the graph is being read in initially. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Jan 13, 2008 at 17:26 UTC 3e76608d39302add89a8ba4a259eb1bf2583dc10
1 file changed +15 -20
gitk
+15 -20
@@ -98,6 +98,7 @@ proc start_rev_list {view} {
98 global showlocalchanges commitinterest mainheadid
99 global progressdirn progresscoords proglastnc curview
100 global viewincl viewactive loginstance viewinstances
101 + global pending_select mainheadid
102
103 set startmsecs [clock clicks -milliseconds]
104 set commitidx($view) 0
@@ -138,6 +139,7 @@ proc start_rev_list {view} {
139 set progressdirn 1
140 set progresscoords {0 0}
141 set proglastnc 0
142 + set pending_select $mainheadid
143 }
144 }
145
@@ -170,7 +172,7 @@ proc updatecommits {} {
172 global curview viewargs viewfiles viewincl viewinstances
173 global viewactive viewcomplete loginstance tclencoding mainheadid
174 global varcid startmsecs commfd showneartags showlocalchanges leftover
173 - global mainheadid
175 + global mainheadid pending_select
176
177 set oldmainid $mainheadid
178 rereadrefs
@@ -228,6 +230,7 @@ proc updatecommits {} {
230 filerun $fd [list getcommitlines $fd $i $view]
231 incr viewactive($view)
232 set viewcomplete($view) 0
233 + set pending_select $mainheadid
234 nowbusy $view "Reading"
235 if {$showneartags} {
236 getallcommits
@@ -2748,9 +2751,9 @@ proc showview {n} {
2751 global numcommits viewcomplete
2752 global selectedline currentid canv canvy0
2753 global treediffs
2751 - global pending_select
2754 + global pending_select mainheadid
2755 global commitidx
2753 - global selectedview selectfirst
2756 + global selectedview
2757 global hlview selectedhlview commitinterest
2758
2759 if {$n == $curview} return
@@ -2812,7 +2815,6 @@ proc showview {n} {
2815 setcanvscroll
2816 set yf 0
2817 set row {}
2815 - set selectfirst 0
2818 if {$selid ne {} && [commitinview $selid $n]} {
2819 set row [rowofcommit $selid]
2820 # try to get the selected row in the same position on the screen
@@ -2827,14 +2829,18 @@ proc showview {n} {
2829 drawvisible
2830 if {$row ne {}} {
2831 selectline $row 0
2830 - } elseif {$selid ne {}} {
2831 - set pending_select $selid
2832 + } elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} {
2833 + selectline [rowofcommit $mainheadid] 1
2834 + } elseif {!$viewcomplete($n)} {
2835 + if {$selid ne {}} {
2836 + set pending_select $selid
2837 + } else {
2838 + set pending_select $mainheadid
2839 + }
2840 } else {
2841 set row [first_real_row]
2842 if {$row < $numcommits} {
2843 selectline $row 0
2836 - } else {
2837 - set selectfirst 1
2844 }
2845 }
2846 if {!$viewcomplete($n)} {
@@ -3440,7 +3446,6 @@ proc initlayout {} {
3446 global numcommits canvxmax canv
3447 global nextcolor
3448 global colormap rowtextx
3443 - global selectfirst
3449
3450 set numcommits 0
3451 set displayorder {}
@@ -3452,7 +3457,6 @@ proc initlayout {} {
3457 set canvxmax [$canv cget -width]
3458 catch {unset colormap}
3459 catch {unset rowtextx}
3455 - set selectfirst 1
3460 }
3461
3462 proc setcanvscroll {} {
@@ -3486,7 +3490,7 @@ proc visiblerows {} {
3490 proc layoutmore {} {
3491 global commitidx viewcomplete curview
3492 global numcommits pending_select selectedline curview
3489 - global selectfirst lastscrollset commitinterest
3493 + global lastscrollset commitinterest
3494
3495 set canshow $commitidx($curview)
3496 if {$canshow <= $numcommits && !$viewcomplete($curview)} return
@@ -3513,15 +3517,6 @@ proc layoutmore {} {
3517 [commitinview $pending_select $curview]} {
3518 selectline [rowofcommit $pending_select] 1
3519 }
3516 - if {$selectfirst} {
3517 - if {[info exists selectedline] || [info exists pending_select]} {
3518 - set selectfirst 0
3519 - } else {
3520 - set l [first_real_row]
3521 - selectline $l 1
3522 - set selectfirst 0
3523 - }
3524 - }
3520 }
3521
3522 proc doshowlocalchanges {} {