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

gitk: Make File->Update work properly again

If a view is selected it will now just update that view. Also fixed a few other things - if you switch away from a view while gitk is still reading it in, then switch back, gitk will re-read it from scratch. We now re-read the references when switching views. If something was selected before a view change, and we need to read in the new view, we now select the previously-selected commit when we come across it. Fixed a bug in setting of rowrangelist plus a couple of other minor things. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Apr 6, 2006 at 10:18 UTC d94f8cd6adc746b850aad421e30d5f90f7f11ee4
1 file changed +30 -29
gitk
+30 -29
@@ -22,8 +22,8 @@ proc parse_args {rargs} {
22 set parsed_args {}
23 set cmdline_files {}
24 if {[catch {
25 - set parse_args [concat --default HEAD $rargs]
26 - set args [split [eval exec git-rev-parse $parse_args] "\n"]
25 + set args [concat --default HEAD $rargs]
26 + set args [split [eval exec git-rev-parse $args] "\n"]
27 set i 0
28 foreach arg $args {
29 if {![regexp {^[0-9a-f]{40}$} $arg]} {
@@ -217,17 +217,13 @@ proc readcommit {id} {
217 }
218
219 proc updatecommits {} {
220 - global parsed_args
220 + global viewdata curview revtreeargs
221
222 - unselectline
223 - stopfindproc
224 - foreach v {matchinglines treediffs currentid} {
225 - global $v
226 - catch {unset $v}
227 - }
228 - clear_display
229 - readrefs
230 - getcommits $parsed_args
222 + set n $curview
223 + set curview -1
224 + catch {unset viewdata($n)}
225 + parse_args $revtreeargs
226 + showview $n
227 }
228
229 proc parsecommit {id contents listed} {
@@ -354,7 +350,7 @@ proc error_popup msg {
350 tkwait window $w
351 }
352
357 -proc makewindow {rargs} {
353 +proc makewindow {} {
354 global canv canv2 canv3 linespc charspc ctext cflist textfont
355 global findtype findtypemenu findloc findstring fstring geometry
356 global entries sha1entry sha1string sha1but
@@ -817,13 +813,6 @@ proc delview {} {
813 showview 0
814 }
815
820 -proc saveview {} {
821 - global curview viewdata
822 - global displayorder parentlist childlist rowidlist rowoffsets
823 - global rowrangelist commitlisted
824 -
825 -}
826 -
816 proc showview {n} {
817 global curview viewdata viewfiles
818 global displayorder parentlist childlist rowidlist rowoffsets
@@ -832,6 +821,7 @@ proc showview {n} {
821 global selectedline currentid canv canvy0
822 global matchinglines treediffs
823 global parsed_args
824 + global pending_select phase
825
826 if {$n == $curview} return
827 set selid {}
@@ -850,7 +840,7 @@ proc showview {n} {
840 }
841 unselectline
842 stopfindproc
853 - if {![info exists viewdata($curview)]} {
843 + if {$curview >= 0 && $phase eq {} && ![info exists viewdata($curview)]} {
844 set viewdata($curview) \
845 [list $displayorder $parentlist $childlist $rowidlist \
846 $rowoffsets $rowrangelist $commitlisted]
@@ -858,6 +848,7 @@ proc showview {n} {
848 catch {unset matchinglines}
849 catch {unset treediffs}
850 clear_display
851 + readrefs
852
853 set curview $n
854 .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
@@ -867,6 +858,7 @@ proc showview {n} {
858 if {$viewfiles($n) ne {}} {
859 set args [concat $args "--" $viewfiles($n)]
860 }
861 + set pending_select $selid
862 getcommits $args
863 return
864 }
@@ -1036,7 +1028,7 @@ proc initlayout {} {
1028 set commitlisted {}
1029 set parentlist {}
1030 set childlist {}
1039 - set rowrangelist {{}}
1031 + set rowrangelist {}
1032 catch {unset children}
1033 set nextcolor 0
1034 set rowidlist {{}}
@@ -1099,7 +1091,7 @@ proc layoutmore {} {
1091 }
1092
1093 proc showstuff {canshow} {
1102 - global numcommits
1094 + global numcommits commitrow pending_select
1095 global linesegends idrowranges idrangedrawn
1096
1097 if {$numcommits == 0} {
@@ -1113,6 +1105,7 @@ proc showstuff {canshow} {
1105 set rows [visiblerows]
1106 set r0 [lindex $rows 0]
1107 set r1 [lindex $rows 1]
1108 + set selrow -1
1109 for {set r $row} {$r < $canshow} {incr r} {
1110 if {[info exists linesegends($r)]} {
1111 foreach id $linesegends($r) {
@@ -1135,6 +1128,11 @@ proc showstuff {canshow} {
1128 drawcmitrow $row
1129 incr row
1130 }
1131 + if {[info exists pending_select] &&
1132 + [info exists commitrow($pending_select)] &&
1133 + $commitrow($pending_select) < $numcommits} {
1134 + selectline $commitrow($pending_select) 1
1135 + }
1136 }
1137
1138 proc layoutrows {row endrow last} {
@@ -1202,10 +1200,12 @@ proc layoutrows {row endrow last} {
1200 } else {
1201 unset idinlist($id)
1202 }
1203 + set ranges {}
1204 if {[info exists idrowranges($id)]} {
1205 lappend idrowranges($id) $row
1207 - lappend rowrangelist $idrowranges($id)
1206 + set ranges $idrowranges($id)
1207 }
1208 + lappend rowrangelist $ranges
1209 incr row
1210 set offs [ntimes [llength $idlist] 0]
1211 set l [llength $newolds]
@@ -1732,8 +1732,8 @@ proc findcrossings {id} {
1732 foreach {s e} [rowranges $id] {
1733 if {$e >= $numcommits} {
1734 set e [expr {$numcommits - 1}]
1735 - if {$e < $s} continue
1735 }
1736 + if {$e <= $s} continue
1737 set x [lsearch -exact [lindex $rowidlist $e] $id]
1738 if {$x < 0} {
1739 puts "findcrossings: oops, no [shortids $id] in row $e"
@@ -2360,7 +2360,7 @@ proc donefilediff {} {
2360 }
2361 }
2362
2363 -proc findcont {id} {
2363 +proc findcont {} {
2364 global findid treediffs parentlist
2365 global ffileline findstartline finddidsel
2366 global displayorder numcommits matchinglines findinprogress
@@ -2493,8 +2493,9 @@ proc selectline {l isnew} {
2493 global canvy0 linespc parentlist childlist
2494 global cflist currentid sha1entry
2495 global commentend idtags linknum
2496 - global mergemax numcommits
2496 + global mergemax numcommits pending_select
2497
2498 + catch {unset pending_select}
2499 $canv delete hover
2500 normalline
2501 if {$l < 0 || $l >= $numcommits} return
@@ -2784,7 +2785,7 @@ proc getmergediffline {mdf id np} {
2785 incr nextupdate 100
2786 fileevent $mdf readable {}
2787 update
2787 - fileevent $mdf readable [list getmergediffline $mdf $id]
2788 + fileevent $mdf readable [list getmergediffline $mdf $id $np]
2789 }
2790 }
2791
@@ -4027,7 +4028,7 @@ set stopped 0
4028 set stuffsaved 0
4029 set patchnum 0
4030 setcoords
4030 -makewindow $revtreeargs
4031 +makewindow
4032 readrefs
4033 parse_args $revtreeargs
4034 set args $parsed_args