gitk: Make it possible to lay out all the rows we have received so far
This arranges things so that we can do the layout all the way up to the last commit that we have received from git log. If we get more commits we re-lay and redisplay (if necessary) the visible rows. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Sep 5, 2007 at 02:19 UTC
f5f3c2e29f51a38261daa91073a3f227d4532325
1 file changed
+91
-36
gitk
+91
-36
@@ -82,11 +82,12 @@ proc dorunq {} {
82
proc start_rev_list {view} {
83
global startmsecs
84
global commfd leftover tclencoding datemode
85
- global viewargs viewfiles commitidx vnextroot
85
+ global viewargs viewfiles commitidx viewcomplete vnextroot
86
global lookingforhead showlocalchanges
87
88
set startmsecs [clock clicks -milliseconds]
89
set commitidx($view) 0
90
+ set viewcomplete($view) 0
91
set vnextroot($view) 0
92
set order "--topo-order"
93
if {$datemode} {
@@ -148,7 +149,7 @@ proc strrep {n} {
149
proc getcommitlines {fd view} {
150
global commitlisted
151
global leftover commfd
151
- global displayorder commitidx commitrow commitdata
152
+ global displayorder commitidx viewcomplete commitrow commitdata
153
global parentlist children curview hlview
154
global vparentlist vdisporder vcmitlisted
155
global ordertok vnextroot idpending
@@ -179,6 +180,7 @@ proc getcommitlines {fd view} {
180
lappend vcmitlisted($view) 0
181
}
182
}
183
+ set viewcomplete($view) 1
184
global viewname
185
unset commfd($view)
186
notbusy $view
@@ -310,15 +312,12 @@ proc getcommitlines {fd view} {
312
}
313
314
proc chewcommits {view} {
313
- global curview hlview commfd
315
+ global curview hlview viewcomplete
316
global selectedline pending_select
317
316
- set more 0
318
if {$view == $curview} {
318
- set allread [expr {![info exists commfd($view)]}]
319
- set tlimit [expr {[clock clicks -milliseconds] + 50}]
320
- set more [layoutmore $tlimit $allread]
321
- if {$allread && !$more} {
319
+ layoutmore
320
+ if {$viewcomplete($view)} {
321
global displayorder commitidx phase
322
global numcommits startmsecs
323
@@ -339,7 +338,7 @@ proc chewcommits {view} {
338
if {[info exists hlview] && $view == $hlview} {
339
vhighlightmore
340
}
342
- return $more
341
+ return 0
342
}
343
344
proc readcommit {id} {
@@ -1949,7 +1948,7 @@ proc unflatten {var l} {
1948
1949
proc showview {n} {
1950
global curview viewdata viewfiles
1952
- global displayorder parentlist rowidlist rowisopt
1951
+ global displayorder parentlist rowidlist rowisopt rowfinal
1952
global colormap rowtextx commitrow nextcolor canvxmax
1953
global numcommits commitlisted
1954
global selectedline currentid canv canvy0
@@ -1985,13 +1984,11 @@ proc showview {n} {
1984
set vparentlist($curview) $parentlist
1985
set vdisporder($curview) $displayorder
1986
set vcmitlisted($curview) $commitlisted
1988
- if {$phase ne {}} {
1989
- set viewdata($curview) \
1990
- [list $phase $rowidlist $rowisopt $numcommits]
1991
- } elseif {![info exists viewdata($curview)]
1992
- || [lindex $viewdata($curview) 0] ne {}} {
1987
+ if {$phase ne {} ||
1988
+ ![info exists viewdata($curview)] ||
1989
+ [lindex $viewdata($curview) 0] ne {}} {
1990
set viewdata($curview) \
1994
- [list {} $rowidlist $rowisopt]
1991
+ [list $phase $rowidlist $rowisopt $rowfinal]
1992
}
1993
}
1994
catch {unset treediffs}
@@ -2023,11 +2020,8 @@ proc showview {n} {
2020
set commitlisted $vcmitlisted($n)
2021
set rowidlist [lindex $v 1]
2022
set rowisopt [lindex $v 2]
2026
- if {$phase eq {}} {
2027
- set numcommits [llength $displayorder]
2028
- } else {
2029
- set numcommits [lindex $v 3]
2030
- }
2023
+ set rowfinal [lindex $v 3]
2024
+ set numcommits $commitidx($n)
2025
2026
catch {unset colormap}
2027
catch {unset rowtextx}
@@ -2660,7 +2654,7 @@ proc idcol {idlist id {i 0}} {
2654
}
2655
2656
proc initlayout {} {
2663
- global rowidlist rowisopt displayorder commitlisted
2657
+ global rowidlist rowisopt rowfinal displayorder commitlisted
2658
global numcommits canvxmax canv
2659
global nextcolor
2660
global parentlist
@@ -2674,6 +2668,7 @@ proc initlayout {} {
2668
set nextcolor 0
2669
set rowidlist {}
2670
set rowisopt {}
2671
+ set rowfinal {}
2672
set canvxmax [$canv cget -width]
2673
catch {unset colormap}
2674
catch {unset rowtextx}
@@ -2708,19 +2703,14 @@ proc visiblerows {} {
2703
return [list $r0 $r1]
2704
}
2705
2711
-proc layoutmore {tmax allread} {
2712
- global commitidx numcommits
2706
+proc layoutmore {} {
2707
+ global commitidx viewcomplete numcommits
2708
global uparrowlen downarrowlen mingaplen curview
2709
2710
set show $commitidx($curview)
2716
- if {!$allread} {
2717
- set delay [expr {$uparrowlen + $mingaplen + $downarrowlen + 3}]
2718
- set show [expr {$show - $delay}]
2719
- }
2711
if {$show > $numcommits} {
2721
- showstuff $show $allread
2712
+ showstuff $show $viewcomplete($curview)
2713
}
2723
- return 0
2714
}
2715
2716
proc showstuff {canshow last} {
@@ -2901,6 +2891,21 @@ proc nextuse {id row} {
2891
return -1
2892
}
2893
2894
+proc prevuse {id row} {
2895
+ global commitrow curview children
2896
+
2897
+ set ret -1
2898
+ if {[info exists children($curview,$id)]} {
2899
+ foreach kid $children($curview,$id) {
2900
+ if {![info exists commitrow($curview,$kid)]} break
2901
+ if {$commitrow($curview,$kid) < $row} {
2902
+ set ret $commitrow($curview,$kid)
2903
+ }
2904
+ }
2905
+ }
2906
+ return $ret
2907
+}
2908
+
2909
proc make_idlist {row} {
2910
global displayorder parentlist uparrowlen downarrowlen mingaplen
2911
global commitidx curview ordertok children commitrow
@@ -2964,11 +2969,42 @@ proc make_idlist {row} {
2969
return $idlist
2970
}
2971
2972
+proc rowsequal {a b} {
2973
+ while {[set i [lsearch -exact $a {}]] >= 0} {
2974
+ set a [lreplace $a $i $i]
2975
+ }
2976
+ while {[set i [lsearch -exact $b {}]] >= 0} {
2977
+ set b [lreplace $b $i $i]
2978
+ }
2979
+ return [expr {$a eq $b}]
2980
+}
2981
+
2982
+proc makeupline {id row rend col} {
2983
+ global rowidlist uparrowlen downarrowlen mingaplen
2984
+
2985
+ for {set r $rend} {1} {set r $rstart} {
2986
+ set rstart [prevuse $id $r]
2987
+ if {$rstart < 0} return
2988
+ if {$rstart < $row} break
2989
+ }
2990
+ if {$rstart + $uparrowlen + $mingaplen + $downarrowlen < $rend} {
2991
+ set rstart [expr {$rend - $uparrowlen - 1}]
2992
+ }
2993
+ for {set r $rstart} {[incr r] <= $row} {} {
2994
+ set idlist [lindex $rowidlist $r]
2995
+ if {$idlist ne {} && [lsearch -exact $idlist $id] < 0} {
2996
+ set col [idcol $idlist $id $col]
2997
+ lset rowidlist $r [linsert $idlist $col $id]
2998
+ changedrow $r
2999
+ }
3000
+ }
3001
+}
3002
+
3003
proc layoutrows {row endrow} {
2968
- global rowidlist rowisopt displayorder
3004
+ global rowidlist rowisopt rowfinal displayorder
3005
global uparrowlen downarrowlen maxwidth mingaplen
3006
global children parentlist
2971
- global commitidx curview commitrow
3007
+ global commitidx viewcomplete curview commitrow
3008
3009
set idlist {}
3010
if {$row > 0} {
@@ -2982,14 +3018,20 @@ proc layoutrows {row endrow} {
3018
set rm1 [expr {$row - 1}]
3019
if {$rm1 < 0 || [lindex $rowidlist $rm1] eq {}} {
3020
set idlist [make_idlist $row]
3021
+ set final 1
3022
} else {
3023
set id [lindex $displayorder $rm1]
3024
+ set final [lindex $rowfinal $rm1]
3025
set col [lsearch -exact $idlist $id]
3026
set idlist [lreplace $idlist $col $col]
3027
foreach p [lindex $parentlist $rm1] {
3028
if {[lsearch -exact $idlist $p] < 0} {
3029
set col [idcol $idlist $p $col]
3030
set idlist [linsert $idlist $col $p]
3031
+ # if not the first child, we have to insert a line going up
3032
+ if {$id ne [lindex $children($curview,$p) 0]} {
3033
+ makeupline $p $rm1 $row $col
3034
+ }
3035
}
3036
}
3037
set id [lindex $displayorder $row]
@@ -3008,6 +3050,9 @@ proc layoutrows {row endrow} {
3050
if {$col < 0} {
3051
set col [idcol $idlist $id]
3052
set idlist [linsert $idlist $col $id]
3053
+ if {$children($curview,$id) ne {}} {
3054
+ makeupline $id $rm1 $row $col
3055
+ }
3056
}
3057
set r [expr {$row + $uparrowlen - 1}]
3058
if {$r < $commitidx($curview)} {
@@ -3032,18 +3077,28 @@ proc layoutrows {row endrow} {
3077
}
3078
}
3079
}
3080
+ if {$final && !$viewcomplete($curview) &&
3081
+ $row + $uparrowlen + $mingaplen + $downarrowlen
3082
+ >= $commitidx($curview)} {
3083
+ set final 0
3084
+ }
3085
set l [llength $rowidlist]
3086
if {$row == $l} {
3087
lappend rowidlist $idlist
3088
lappend rowisopt 0
3089
+ lappend rowfinal $final
3090
} elseif {$row < $l} {
3040
- if {$idlist ne [lindex $rowidlist $row]} {
3091
+ if {![rowsequal $idlist [lindex $rowidlist $row]]} {
3092
lset rowidlist $row $idlist
3093
+ lset rowfinal $row $final
3094
changedrow $row
3095
}
3096
} else {
3045
- set rowidlist [concat $rowidlist [ntimes [expr {$row - $l}] {}]]
3097
+ set pad [ntimes [expr {$row - $l}] {}]
3098
+ set rowidlist [concat $rowidlist $pad]
3099
lappend rowidlist $idlist
3100
+ set rowfinal [concat $rowfinal $pad]
3101
+ lappend rowfinal $final
3102
set rowisopt [concat $rowisopt [ntimes [expr {$row - $l + 1}] 0]]
3103
}
3104
}
@@ -3659,7 +3714,7 @@ proc drawcmitrow {row} {
3714
3715
proc drawcommits {row {endrow {}}} {
3716
global numcommits iddrawn displayorder curview need_redisplay
3662
- global parentlist rowidlist uparrowlen downarrowlen nrows_drawn
3717
+ global parentlist rowidlist rowfinal uparrowlen downarrowlen nrows_drawn
3718
3719
if {$row < 0} {
3720
set row 0
@@ -3684,7 +3739,7 @@ proc drawcommits {row {endrow {}}} {
3739
set r2 $numcommits
3740
}
3741
for {set r $rl1} {$r < $r2} {incr r} {
3687
- if {[lindex $rowidlist $r] ne {}} {
3742
+ if {[lindex $rowidlist $r] ne {} && [lindex $rowfinal $r]} {
3743
if {$rl1 < $r} {
3744
layoutrows $rl1 $r
3745
}