}
proc getcommits {rargs} {
- global oldcommits commits phase canv mainfont env
+ global phase canv mainfont
- # check that we can find a .git directory somewhere...
- set gitdir [gitdir]
- if {![file isdirectory $gitdir]} {
- error_popup "Cannot find the git directory \"$gitdir\"."
- exit 1
- }
- set oldcommits {}
- set commits {}
set phase getcommits
start_rev_list [parse_args $rargs]
$canv delete all
}
proc getcommitlines {commfd} {
- global oldcommits commits parents cdate children nchildren
- global commitlisted phase nextupdate
+ global parents cdate children nchildren
+ global commitlisted nextupdate
global stopped leftover
global canv
set id [lindex $ids 0]
set olds [lrange $ids 1 end]
set cmit [string range $cmit [expr {$j + 1}] end]
- lappend commits $id
set commitlisted($id) 1
parsecommit $id $cmit 1 [lrange $ids 1 end]
drawcommit $id 1
}
proc updatecommits {rargs} {
- global commitlisted commfd phase
- global startmsecs nextupdate ncmupdate
- global idtags idheads idotherrefs
- global leftover
- global parsed_args
- global canv mainfont
- global oldcommits commits
- global parents nchildren children
-
- set old_args $parsed_args
- parse_args $rargs
-
- if {$phase == "getcommits" || $phase == "incrdraw"} {
- # havent read all the old commits, just start again from scratch
- stopfindproc
- set oldcommits {}
- set commits {}
- foreach v {children nchildren parents commitlisted commitinfo
- selectedline matchinglines treediffs
- mergefilelist currentid rowtextx} {
- global $v
- catch {unset $v}
- }
- readrefs
- if {$phase == "incrdraw"} {
- allcanvs delete all
- $canv create text 3 3 -anchor nw -text "Reading commits..." \
- -font $mainfont -tags textitems
- set phase getcommits
- }
- start_rev_list $parsed_args
- return
- }
-
- foreach id $old_args {
- if {![regexp {^[0-9a-f]{40}$} $id]} continue
- if {[info exists oldref($id)]} continue
- set oldref($id) $id
- lappend ignoreold "^$id"
- }
- foreach id $parsed_args {
- if {![regexp {^[0-9a-f]{40}$} $id]} continue
- if {[info exists ref($id)]} continue
- set ref($id) $id
- lappend ignorenew "^$id"
- }
-
- foreach a $old_args {
- if {![info exists ref($a)]} {
- lappend ignorenew $a
- }
- }
-
- set phase updatecommits
- set oldcommits $commits
- set commits {}
- set removed_commits [split [eval exec git-rev-list $ignorenew] "\n" ]
- if {[llength $removed_commits] > 0} {
- allcanvs delete all
- foreach c $removed_commits {
- set i [lsearch -exact $oldcommits $c]
- if {$i >= 0} {
- set oldcommits [lreplace $oldcommits $i $i]
- unset commitlisted($c)
- foreach p $parents($c) {
- if {[info exists nchildren($p)]} {
- set j [lsearch -exact $children($p) $c]
- if {$j >= 0} {
- set children($p) [lreplace $children($p) $j $j]
- incr nchildren($p) -1
- }
- }
- }
- }
- }
- set phase removecommits
- }
-
- set args {}
- foreach a $parsed_args {
- if {![info exists oldref($a)]} {
- lappend args $a
- }
+ stopfindproc
+ foreach v {children nchildren parents nparents commitlisted
+ commitinfo colormap selectedline matchinglines treediffs
+ mergefilelist currentid rowtextx commitrow lineid
+ rowidlist rowoffsets idrowranges idrangedrawn iddrawn
+ linesegends crossings cornercrossings} {
+ global $v
+ catch {unset $v}
}
-
+ allcanvs delete all
readrefs
- start_rev_list [concat $ignoreold $args]
+ getcommits $rargs
}
proc updatechildren {id olds} {
}
proc assigncolor {id} {
- global colormap commcolors colors nextcolor
+ global colormap colors nextcolor
global parents nparents children nchildren
global cornercrossings crossings
allcanvs delete all
set nextcolor 0
set numcommits 0
- foreach v {colormap cornercrossings crossings lineid} {
- global $v
- catch {unset $v}
- }
}
proc bindline {t id} {
}
proc finishcommits {} {
- global phase oldcommits commits
+ global phase
global canv mainfont ctext maincursor textcursor
- global parents todo
- if {$phase == "incrdraw" || $phase == "removecommits"} {
- foreach id $oldcommits {
- lappend commits $id
- drawcommit $id 0
- }
- set oldcommits {}
+ if {$phase == "incrdraw"} {
drawrest
- } elseif {$phase == "updatecommits"} {
- # there were no new commits, in fact
- set commits $oldcommits
- set oldcommits {}
- set phase {}
} else {
$canv delete all
$canv create text 3 3 -anchor nw -text "No commits selected" \
}
proc clickisonarrow {id y} {
- global mainline mainlinearrow sidelines lthickness
+ global lthickness idrowranges
set thresh [expr {2 * $lthickness + 6}]
- if {[info exists mainline($id)]} {
- if {$mainlinearrow($id) ne "none"} {
- if {abs([lindex $mainline($id) 1] - $y) < $thresh} {
- return "up"
- }
- }
- }
- if {[info exists sidelines($id)]} {
- foreach ls $sidelines($id) {
- set coords [lindex $ls 0]
- set arrow [lindex $ls 2]
- if {$arrow eq "first" || $arrow eq "both"} {
- if {abs([lindex $coords 1] - $y) < $thresh} {
- return "up"
- }
- }
- if {$arrow eq "last" || $arrow eq "both"} {
- if {abs([lindex $coords end] - $y) < $thresh} {
- return "down"
- }
- }
+ set n [expr {[llength $idrowranges($id)] - 1}]
+ for {set i 1} {$i < $n} {incr i} {
+ set row [lindex $idrowranges($id) $i]
+ if {abs([yc $row] - $y) < $thresh} {
+ return $i
}
}
return {}
}
-proc arrowjump {id dirn y} {
- global mainline sidelines canv canv2 canv3
+proc arrowjump {id n y} {
+ global idrowranges canv
- set yt {}
- if {$dirn eq "down"} {
- if {[info exists mainline($id)]} {
- set y1 [lindex $mainline($id) 1]
- if {$y1 > $y} {
- set yt $y1
- }
- }
- if {[info exists sidelines($id)]} {
- foreach ls $sidelines($id) {
- set y1 [lindex $ls 0 1]
- if {$y1 > $y && ($yt eq {} || $y1 < $yt)} {
- set yt $y1
- }
- }
- }
- } else {
- if {[info exists sidelines($id)]} {
- foreach ls $sidelines($id) {
- set y1 [lindex $ls 0 end]
- if {$y1 < $y && ($yt eq {} || $y1 > $yt)} {
- set yt $y1
- }
- }
- }
- }
- if {$yt eq {}} return
+ # 1 <-> 2, 3 <-> 4, etc...
+ set n [expr {(($n - 1) ^ 1) + 1}]
+ set row [lindex $idrowranges($id) $n]
+ set yt [yc $row]
set ymax [lindex [$canv cget -scrollregion] 3]
if {$ymax eq {} || $ymax <= 0} return
set view [$canv yview]
if {$yfrac < 0} {
set yfrac 0
}
- $canv yview moveto $yfrac
- $canv2 yview moveto $yfrac
- $canv3 yview moveto $yfrac
+ allcanvs yview moveto $yfrac
}
proc lineclick {x y id isnew} {
}
}
+# check that we can find a .git directory somewhere...
+set gitdir [gitdir]
+if {![file isdirectory $gitdir]} {
+ error_popup "Cannot find the git directory \"$gitdir\"."
+ exit 1
+}
+
set history {}
set historyindex 0