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

gitk: Fix Update menu item

This just does the simple thing of resetting everything, reading all the commits, and redoing the whole layout from scratch. Hopefully things are now fast enough that this simple approach is acceptable. Also, this fits in better with future plans for adding the ability to restrict the tree to just a few files and then expand back to the whole tree. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Feb 28, 2006 at 11:27 UTC aa81d97476de941015224c99092cb1f49f451a23
1 file changed +23 -115
gitk
+23 -115
@@ -61,16 +61,8 @@ proc start_rev_list {rlargs} {
61 }
62
63 proc getcommits {rargs} {
64 - global oldcommits commits phase canv mainfont env
64 + global phase canv mainfont
65
66 - # check that we can find a .git directory somewhere...
67 - set gitdir [gitdir]
68 - if {![file isdirectory $gitdir]} {
69 - error_popup "Cannot find the git directory \"$gitdir\"."
70 - exit 1
71 - }
72 - set oldcommits {}
73 - set commits {}
66 set phase getcommits
67 start_rev_list [parse_args $rargs]
68 $canv delete all
@@ -79,8 +71,8 @@ proc getcommits {rargs} {
71 }
72
73 proc getcommitlines {commfd} {
82 - global oldcommits commits parents cdate children nchildren
83 - global commitlisted phase nextupdate
74 + global parents cdate children nchildren
75 + global commitlisted nextupdate
76 global stopped leftover
77 global canv
78
@@ -140,7 +132,6 @@ proc getcommitlines {commfd} {
132 set id [lindex $ids 0]
133 set olds [lrange $ids 1 end]
134 set cmit [string range $cmit [expr {$j + 1}] end]
143 - lappend commits $id
135 set commitlisted($id) 1
136 parsecommit $id $cmit 1 [lrange $ids 1 end]
137 drawcommit $id 1
@@ -177,93 +168,18 @@ proc readcommit {id} {
168 }
169
170 proc updatecommits {rargs} {
180 - global commitlisted commfd phase
181 - global startmsecs nextupdate ncmupdate
182 - global idtags idheads idotherrefs
183 - global leftover
184 - global parsed_args
185 - global canv mainfont
186 - global oldcommits commits
187 - global parents nchildren children
188 -
189 - set old_args $parsed_args
190 - parse_args $rargs
191 -
192 - if {$phase == "getcommits" || $phase == "incrdraw"} {
193 - # havent read all the old commits, just start again from scratch
194 - stopfindproc
195 - set oldcommits {}
196 - set commits {}
197 - foreach v {children nchildren parents commitlisted commitinfo
198 - selectedline matchinglines treediffs
199 - mergefilelist currentid rowtextx} {
200 - global $v
201 - catch {unset $v}
202 - }
203 - readrefs
204 - if {$phase == "incrdraw"} {
205 - allcanvs delete all
206 - $canv create text 3 3 -anchor nw -text "Reading commits..." \
207 - -font $mainfont -tags textitems
208 - set phase getcommits
209 - }
210 - start_rev_list $parsed_args
211 - return
212 - }
213 -
214 - foreach id $old_args {
215 - if {![regexp {^[0-9a-f]{40}$} $id]} continue
216 - if {[info exists oldref($id)]} continue
217 - set oldref($id) $id
218 - lappend ignoreold "^$id"
219 - }
220 - foreach id $parsed_args {
221 - if {![regexp {^[0-9a-f]{40}$} $id]} continue
222 - if {[info exists ref($id)]} continue
223 - set ref($id) $id
224 - lappend ignorenew "^$id"
225 - }
226 -
227 - foreach a $old_args {
228 - if {![info exists ref($a)]} {
229 - lappend ignorenew $a
230 - }
231 - }
232 -
233 - set phase updatecommits
234 - set oldcommits $commits
235 - set commits {}
236 - set removed_commits [split [eval exec git-rev-list $ignorenew] "\n" ]
237 - if {[llength $removed_commits] > 0} {
238 - allcanvs delete all
239 - foreach c $removed_commits {
240 - set i [lsearch -exact $oldcommits $c]
241 - if {$i >= 0} {
242 - set oldcommits [lreplace $oldcommits $i $i]
243 - unset commitlisted($c)
244 - foreach p $parents($c) {
245 - if {[info exists nchildren($p)]} {
246 - set j [lsearch -exact $children($p) $c]
247 - if {$j >= 0} {
248 - set children($p) [lreplace $children($p) $j $j]
249 - incr nchildren($p) -1
250 - }
251 - }
252 - }
253 - }
254 - }
255 - set phase removecommits
256 - }
257 -
258 - set args {}
259 - foreach a $parsed_args {
260 - if {![info exists oldref($a)]} {
261 - lappend args $a
262 - }
171 + stopfindproc
172 + foreach v {children nchildren parents nparents commitlisted
173 + commitinfo colormap selectedline matchinglines treediffs
174 + mergefilelist currentid rowtextx commitrow lineid
175 + rowidlist rowoffsets idrowranges idrangedrawn iddrawn
176 + linesegends crossings cornercrossings} {
177 + global $v
178 + catch {unset $v}
179 }
264 -
180 + allcanvs delete all
181 readrefs
266 - start_rev_list [concat $ignoreold $args]
182 + getcommits $rargs
183 }
184
185 proc updatechildren {id olds} {
@@ -1456,7 +1372,7 @@ proc clear_display {} {
1372 }
1373
1374 proc assigncolor {id} {
1459 - global colormap commcolors colors nextcolor
1375 + global colormap colors nextcolor
1376 global parents nparents children nchildren
1377 global cornercrossings crossings
1378
@@ -1533,10 +1449,6 @@ proc initgraph {} {
1449 allcanvs delete all
1450 set nextcolor 0
1451 set numcommits 0
1536 - foreach v {colormap cornercrossings crossings lineid} {
1537 - global $v
1538 - catch {unset $v}
1539 - }
1452 }
1453
1454 proc bindline {t id} {
@@ -1696,22 +1608,11 @@ proc drawcommit {id reading} {
1608 }
1609
1610 proc finishcommits {} {
1699 - global phase oldcommits commits
1611 + global phase
1612 global canv mainfont ctext maincursor textcursor
1701 - global parents todo
1613
1703 - if {$phase == "incrdraw" || $phase == "removecommits"} {
1704 - foreach id $oldcommits {
1705 - lappend commits $id
1706 - drawcommit $id 0
1707 - }
1708 - set oldcommits {}
1614 + if {$phase == "incrdraw"} {
1615 drawrest
1710 - } elseif {$phase == "updatecommits"} {
1711 - # there were no new commits, in fact
1712 - set commits $oldcommits
1713 - set oldcommits {}
1714 - set phase {}
1616 } else {
1617 $canv delete all
1618 $canv create text 3 3 -anchor nw -text "No commits selected" \
@@ -3773,6 +3674,13 @@ foreach arg $argv {
3674 }
3675 }
3676
3677 +# check that we can find a .git directory somewhere...
3678 +set gitdir [gitdir]
3679 +if {![file isdirectory $gitdir]} {
3680 + error_popup "Cannot find the git directory \"$gitdir\"."
3681 + exit 1
3682 +}
3683 +
3684 set history {}
3685 set historyindex 0
3686