X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=gitk;h=c443d951361a534737462d6eccdd20a9c92e95dd;hb=244edd1241cc6168fba0b580c41a6adeb63f1216;hp=6a6d4b243593147eaf9d10b23e78a2c1d0c520aa;hpb=466e4fdd6696c89700294e1a54fa73e1fb94643b;p=git.git diff --git a/gitk b/gitk index 6a6d4b24..c443d951 100755 --- a/gitk +++ b/gitk @@ -31,7 +31,7 @@ proc getcommits {rargs} { set phase getcommits set startmsecs [clock clicks -milliseconds] set nextupdate [expr $startmsecs + 100] - set ncmupdate 0 + set ncmupdate 1 if [catch { set parse_args [concat --default HEAD $rargs] set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"] @@ -62,7 +62,6 @@ proc getcommitlines {commfd} { global commits parents cdate children nchildren global commitlisted phase commitinfo nextupdate global stopped redisplaying leftover - global numcommits ncmupdate set stuff [read $commfd] if {$stuff == {}} { @@ -110,10 +109,8 @@ to allow selection of commits to be displayed.)} set commitlisted($id) 1 parsecommit $id $cmit 1 drawcommit $id - if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - doupdate - set ncmupdate $numcommits + if {[clock clicks -milliseconds] >= $nextupdate} { + doupdate 1 } while {$redisplaying} { set redisplaying 0 @@ -123,10 +120,8 @@ to allow selection of commits to be displayed.)} foreach id $commits { drawcommit $id if {$stopped} break - if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - doupdate - set ncmupdate $numcommits + if {[clock clicks -milliseconds] >= $nextupdate} { + doupdate 1 } } } @@ -134,13 +129,24 @@ to allow selection of commits to be displayed.)} } } -proc doupdate {} { - global commfd nextupdate +proc doupdate {reading} { + global commfd nextupdate numcommits ncmupdate - incr nextupdate 100 - fileevent $commfd readable {} + if {$reading} { + fileevent $commfd readable {} + } update - fileevent $commfd readable [list getcommitlines $commfd] + set nextupdate [expr {[clock clicks -milliseconds] + 100}] + if {$numcommits < 100} { + set ncmupdate [expr {$numcommits + 1}] + } elseif {$numcommits < 10000} { + set ncmupdate [expr {$numcommits + 10}] + } else { + set ncmupdate [expr {$numcommits + 100}] + } + if {$reading} { + fileevent $commfd readable [list getcommitlines $commfd] + } } proc readcommit {id} { @@ -150,6 +156,7 @@ proc readcommit {id} { proc parsecommit {id contents listed} { global commitinfo children nchildren parents nparents cdate ncleft + global grafts set inhdr 1 set comment {} @@ -165,13 +172,32 @@ proc parsecommit {id contents listed} { } set parents($id) {} set nparents($id) 0 + set grafted 0 + if {[info exists grafts($id)]} { + set grafted 1 + set parents($id) $grafts($id) + set nparents($id) [llength $grafts($id)] + if {$listed} { + foreach p $grafts($id) { + if {![info exists nchildren($p)]} { + set children($p) [list $id] + set nchildren($p) 1 + set ncleft($p) 1 + } elseif {[lsearch -exact $children($p) $id] < 0} { + lappend children($p) $id + incr nchildren($p) + incr ncleft($p) + } + } + } + } foreach line [split $contents "\n"] { if {$inhdr} { if {$line == {}} { set inhdr 0 } else { set tag [lindex $line 0] - if {$tag == "parent"} { + if {$tag == "parent" && !$grafted} { set p [lindex $line 1] if {![info exists nchildren($p)]} { set children($p) {} @@ -267,6 +293,32 @@ proc readrefs {} { } } +proc readgrafts {} { + global grafts env + catch { + set graftfile info/grafts + if {[info exists env(GIT_GRAFT_FILE)]} { + set graftfile $env(GIT_GRAFT_FILE) + } + set fd [open [gitdir]/$graftfile r] + while {[gets $fd line] >= 0} { + if {[string match "#*" $line]} continue + set ok 1 + foreach x $line { + if {![regexp {^[0-9a-f]{40}$} $x]} { + set ok 0 + break + } + } + if {$ok} { + set id [lindex $line 0] + set grafts($id) [lrange $line 1 end] + } + } + close $fd + } +} + proc error_popup msg { set w .error toplevel $w @@ -1127,8 +1179,7 @@ proc drawcommit {id} { } if {[clock clicks -milliseconds] >= $nextupdate && $numcommits >= $ncmupdate} { - doupdate - set ncmupdate $numcommits + doupdate 1 if {$stopped} break } } @@ -1171,7 +1222,7 @@ proc drawgraph {} { if {$startcommits == {}} return set startmsecs [clock clicks -milliseconds] set nextupdate [expr $startmsecs + 100] - set ncmupdate 0 + set ncmupdate 1 initgraph set todo [lindex $startcommits 0] drawrest 0 1 @@ -1210,10 +1261,8 @@ proc drawrest {level startix} { drawslants $level } if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - update - incr nextupdate 100 - set ncmupdate $numcommits + && $numcommits >= $ncmupdate} { + doupdate 0 } } } @@ -3199,4 +3248,5 @@ set patchnum 0 setcoords makewindow readrefs +readgrafts getcommits $revtreeargs