@matheusbsbs / matheus-bagliano / commits / 50b44eceed
Fork 0

gitk: Implement multiple views

With this, gitk can know about the graphs for multiple sets of files and directories of interest. Each set of files/dirs and its graph is called a "view". There is always the "All files" view, which is the complete graph showing all commits. If files or dirs are specified on the command line, a "Command line" view is automatically created. Users can create new views and switch between them, and can delete any view except the "All files" view. This required a bit of reengineering. In particular, some more things that were arrays have now become lists. The idrowranges array is still used while the graph is being laid out, but for rows that have been laid out we use the rowrangelist list instead. The cornercrossings and crossings arrays no longer exist, and instead we compute the crossings when needed (in assigncolor). Still to be done: make the back/forward buttons switch views as necessary; make the updatecommits function work right; preserve the selection if possible when the new view has to be read in; fix the case when the user switches away from the current view while we are still reading it in and laying it out; further optimizations. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Apr 4, 2006 at 10:16 UTC 50b44eceed2105db0bee194904649249cc5f0308
1 file changed +334 -118
gitk
+334 -118
@@ -17,19 +17,38 @@ proc gitdir {} {
17 }
18
19 proc parse_args {rargs} {
20 - global parsed_args
20 + global parsed_args cmdline_files
21
22 + set parsed_args {}
23 + set cmdline_files {}
24 if {[catch {
25 set parse_args [concat --default HEAD $rargs]
24 - set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
26 + set args [split [eval exec git-rev-parse $parse_args] "\n"]
27 + set i 0
28 + foreach arg $args {
29 + if {![regexp {^[0-9a-f]{40}$} $arg]} {
30 + if {$arg eq "--"} {
31 + incr i
32 + }
33 + set cmdline_files [lrange $args $i end]
34 + break
35 + }
36 + lappend parsed_args $arg
37 + incr i
38 + }
39 }]} {
40 # if git-rev-parse failed for some reason...
41 + set i [lsearch -exact $rargs "--"]
42 + if {$i >= 0} {
43 + set cmdline_files [lrange $rargs [expr {$i+1}] end]
44 + set rargs [lrange $rargs 0 [expr {$i-1}]]
45 + }
46 if {$rargs == {}} {
28 - set rargs HEAD
47 + set parsed_args HEAD
48 + } else {
49 + set parsed_args $rargs
50 }
30 - set parsed_args $rargs
51 }
32 - return $parsed_args
52 }
53
54 proc start_rev_list {rlargs} {
@@ -65,7 +84,7 @@ proc getcommits {rargs} {
84 global phase canv mainfont
85
86 set phase getcommits
68 - start_rev_list [parse_args $rargs]
87 + start_rev_list $rargs
88 $canv delete all
89 $canv create text 3 3 -anchor nw -text "Reading commits..." \
90 -font $mainfont -tags textitems
@@ -141,11 +160,12 @@ proc getcommitlines {commfd} {
160 set id [lindex $ids 0]
161 if {$listed} {
162 set olds [lrange $ids 1 end]
144 - if {[llength $olds] > 1} {
145 - set olds [lsort -unique $olds]
146 - }
163 + set i 0
164 foreach p $olds {
148 - lappend children($p) $id
165 + if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
166 + lappend children($p) $id
167 + }
168 + incr i
169 }
170 } else {
171 set olds {}
@@ -196,18 +216,18 @@ proc readcommit {id} {
216 parsecommit $id $contents 0
217 }
218
199 -proc updatecommits {rargs} {
219 +proc updatecommits {} {
220 + global parsed_args
221 +
222 + unselectline
223 stopfindproc
201 - foreach v {colormap selectedline matchinglines treediffs
202 - mergefilelist currentid rowtextx commitrow
203 - rowidlist rowoffsets idrowranges idrangedrawn iddrawn
204 - linesegends crossings cornercrossings} {
224 + foreach v {matchinglines treediffs currentid} {
225 global $v
226 catch {unset $v}
227 }
208 - allcanvs delete all
228 + clear_display
229 readrefs
210 - getcommits $rargs
230 + getcommits $parsed_args
231 }
232
233 proc parsecommit {id contents listed} {
@@ -344,12 +364,18 @@ proc makewindow {rargs} {
364 menu .bar
365 .bar add cascade -label "File" -menu .bar.file
366 menu .bar.file
347 - .bar.file add command -label "Update" -command [list updatecommits $rargs]
367 + .bar.file add command -label "Update" -command updatecommits
368 .bar.file add command -label "Reread references" -command rereadrefs
369 .bar.file add command -label "Quit" -command doquit
370 menu .bar.edit
371 .bar add cascade -label "Edit" -menu .bar.edit
372 .bar.edit add command -label "Preferences" -command doprefs
373 + menu .bar.view
374 + .bar add cascade -label "View" -menu .bar.view
375 + .bar.view add command -label "New view..." -command newview
376 + .bar.view add command -label "Delete view" -command delview -state disabled
377 + .bar.view add separator
378 + .bar.view add command -label "All files" -command {showview 0}
379 menu .bar.help
380 .bar add cascade -label "Help" -menu .bar.help
381 .bar.help add command -label "About gitk" -command about
@@ -718,6 +744,169 @@ Use and redistribute under the terms of the GNU General Public License} \
744 pack $w.ok -side bottom
745 }
746
747 +proc newview {} {
748 + global newviewname nextviewnum newviewtop
749 +
750 + set top .gitkview
751 + if {[winfo exists $top]} {
752 + raise $top
753 + return
754 + }
755 + set newviewtop $top
756 + toplevel $top
757 + wm title $top "Gitk view definition"
758 + label $top.nl -text "Name"
759 + entry $top.name -width 20 -textvariable newviewname
760 + set newviewname "View $nextviewnum"
761 + grid $top.nl $top.name -sticky w
762 + label $top.l -text "Files and directories to include:"
763 + grid $top.l - -sticky w -pady 10
764 + text $top.t -width 30 -height 10
765 + grid $top.t - -sticky w
766 + frame $top.buts
767 + button $top.buts.ok -text "OK" -command newviewok
768 + button $top.buts.can -text "Cancel" -command newviewcan
769 + grid $top.buts.ok $top.buts.can
770 + grid columnconfigure $top.buts 0 -weight 1 -uniform a
771 + grid columnconfigure $top.buts 1 -weight 1 -uniform a
772 + grid $top.buts - -pady 10 -sticky ew
773 + focus $top.t
774 +}
775 +
776 +proc newviewok {} {
777 + global newviewtop nextviewnum
778 + global viewname viewfiles
779 +
780 + set n $nextviewnum
781 + incr nextviewnum
782 + set viewname($n) [$newviewtop.name get]
783 + set files {}
784 + foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
785 + set ft [string trim $f]
786 + if {$ft ne {}} {
787 + lappend files $ft
788 + }
789 + }
790 + set viewfiles($n) $files
791 + catch {destroy $newviewtop}
792 + unset newviewtop
793 + .bar.view add command -label $viewname($n) -command [list showview $n]
794 + after idle showview $n
795 +}
796 +
797 +proc newviewcan {} {
798 + global newviewtop
799 +
800 + catch {destroy $newviewtop}
801 + unset newviewtop
802 +}
803 +
804 +proc delview {} {
805 + global curview viewdata
806 +
807 + if {$curview == 0} return
808 + set nmenu [.bar.view index end]
809 + set targetcmd [list showview $curview]
810 + for {set i 5} {$i <= $nmenu} {incr i} {
811 + if {[.bar.view entrycget $i -command] eq $targetcmd} {
812 + .bar.view delete $i
813 + break
814 + }
815 + }
816 + set viewdata($curview) {}
817 + showview 0
818 +}
819 +
820 +proc saveview {} {
821 + global curview viewdata
822 + global displayorder parentlist childlist rowidlist rowoffsets
823 + global rowrangelist commitlisted
824 +
825 +}
826 +
827 +proc showview {n} {
828 + global curview viewdata viewfiles
829 + global displayorder parentlist childlist rowidlist rowoffsets
830 + global colormap rowtextx commitrow
831 + global numcommits rowrangelist commitlisted idrowranges
832 + global selectedline currentid canv canvy0
833 + global matchinglines treediffs
834 + global parsed_args
835 +
836 + if {$n == $curview} return
837 + set selid {}
838 + if {[info exists selectedline]} {
839 + set selid $currentid
840 + set y [yc $selectedline]
841 + set ymax [lindex [$canv cget -scrollregion] 3]
842 + set span [$canv yview]
843 + set ytop [expr {[lindex $span 0] * $ymax}]
844 + set ybot [expr {[lindex $span 1] * $ymax}]
845 + if {$ytop < $y && $y < $ybot} {
846 + set yscreen [expr {$y - $ytop}]
847 + } else {
848 + set yscreen [expr {($ybot - $ytop) / 2}]
849 + }
850 + }
851 + unselectline
852 + stopfindproc
853 + if {![info exists viewdata($curview)]} {
854 + set viewdata($curview) \
855 + [list $displayorder $parentlist $childlist $rowidlist \
856 + $rowoffsets $rowrangelist $commitlisted]
857 + }
858 + catch {unset matchinglines}
859 + catch {unset treediffs}
860 + clear_display
861 +
862 + set curview $n
863 + .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
864 +
865 + if {![info exists viewdata($n)]} {
866 + set args $parsed_args
867 + if {$viewfiles($n) ne {}} {
868 + set args [concat $args "--" $viewfiles($n)]
869 + }
870 + getcommits $args
871 + return
872 + }
873 +
874 + set displayorder [lindex $viewdata($n) 0]
875 + set parentlist [lindex $viewdata($n) 1]
876 + set childlist [lindex $viewdata($n) 2]
877 + set rowidlist [lindex $viewdata($n) 3]
878 + set rowoffsets [lindex $viewdata($n) 4]
879 + set rowrangelist [lindex $viewdata($n) 5]
880 + set commitlisted [lindex $viewdata($n) 6]
881 + set numcommits [llength $displayorder]
882 + catch {unset colormap}
883 + catch {unset rowtextx}
884 + catch {unset commitrow}
885 + catch {unset idrowranges}
886 + set curview $n
887 + set row 0
888 + foreach id $displayorder {
889 + set commitrow($id) $row
890 + incr row
891 + }
892 + setcanvscroll
893 + set yf 0
894 + set row 0
895 + if {$selid ne {} && [info exists commitrow($selid)]} {
896 + set row $commitrow($selid)
897 + # try to get the selected row in the same position on the screen
898 + set ymax [lindex [$canv cget -scrollregion] 3]
899 + set ytop [expr {[yc $row] - $yscreen}]
900 + if {$ytop < 0} {
901 + set ytop 0
902 + }
903 + set yf [expr {$ytop * 1.0 / $ymax}]
904 + }
905 + allcanvs yview moveto $yf
906 + drawvisible
907 + selectline $row 0
908 +}
909 +
910 proc shortids {ids} {
911 set res {}
912 foreach id $ids {
@@ -834,10 +1023,12 @@ proc makeuparrow {oid x y z} {
1023 proc initlayout {} {
1024 global rowidlist rowoffsets displayorder commitlisted
1025 global rowlaidout rowoptim
837 - global idinlist rowchk
1026 + global idinlist rowchk rowrangelist idrowranges
1027 global commitidx numcommits canvxmax canv
1028 global nextcolor
1029 global parentlist childlist children
1030 + global colormap rowtextx commitrow
1031 + global linesegends
1032
1033 set commitidx 0
1034 set numcommits 0
@@ -845,6 +1036,7 @@ proc initlayout {} {
1036 set commitlisted {}
1037 set parentlist {}
1038 set childlist {}
1039 + set rowrangelist {{}}
1040 catch {unset children}
1041 set nextcolor 0
1042 set rowidlist {{}}
@@ -854,6 +1046,11 @@ proc initlayout {} {
1046 set rowlaidout 0
1047 set rowoptim 0
1048 set canvxmax [$canv cget -width]
1049 + catch {unset colormap}
1050 + catch {unset rowtextx}
1051 + catch {unset commitrow}
1052 + catch {unset idrowranges}
1053 + catch {unset linesegends}
1054 }
1055
1056 proc setcanvscroll {} {
@@ -892,7 +1089,6 @@ proc layoutmore {} {
1089 set rowlaidout [layoutrows $row $commitidx 0]
1090 set orow [expr {$rowlaidout - $uparrowlen - 1}]
1091 if {$orow > $rowoptim} {
895 - checkcrossings $rowoptim $orow
1092 optimize_rows $rowoptim 0 $orow
1093 set rowoptim $orow
1094 }
@@ -947,7 +1143,7 @@ proc layoutrows {row endrow last} {
1143 global childlist parentlist
1144 global idrowranges linesegends
1145 global commitidx
950 - global idinlist rowchk
1146 + global idinlist rowchk rowrangelist
1147
1148 set idlist [lindex $rowidlist $row]
1149 set offs [lindex $rowoffsets $row]
@@ -1008,6 +1204,7 @@ proc layoutrows {row endrow last} {
1204 }
1205 if {[info exists idrowranges($id)]} {
1206 lappend idrowranges($id) $row
1207 + lappend rowrangelist $idrowranges($id)
1208 }
1209 incr row
1210 set offs [ntimes [llength $idlist] 0]
@@ -1068,7 +1265,7 @@ proc addextraid {id row} {
1265
1266 proc layouttail {} {
1267 global rowidlist rowoffsets idinlist commitidx
1071 - global idrowranges
1268 + global idrowranges rowrangelist
1269
1270 set row $commitidx
1271 set idlist [lindex $rowidlist $row]
@@ -1078,6 +1275,7 @@ proc layouttail {} {
1275 addextraid $id $row
1276 unset idinlist($id)
1277 lappend idrowranges($id) $row
1278 + lappend rowrangelist $idrowranges($id)
1279 incr row
1280 set offs [ntimes $col 0]
1281 set idlist [lreplace $idlist $col $col]
@@ -1091,6 +1289,7 @@ proc layouttail {} {
1289 lset rowoffsets $row 0
1290 makeuparrow $id 0 $row 0
1291 lappend idrowranges($id) $row
1292 + lappend rowrangelist $idrowranges($id)
1293 incr row
1294 lappend rowidlist {}
1295 lappend rowoffsets {}
@@ -1107,7 +1306,7 @@ proc insert_pad {row col npad} {
1306 }
1307
1308 proc optimize_rows {row col endrow} {
1110 - global rowidlist rowoffsets idrowranges linesegends displayorder
1309 + global rowidlist rowoffsets idrowranges displayorder
1310
1311 for {} {$row < $endrow} {incr row} {
1312 set idlist [lindex $rowidlist $row]
@@ -1240,13 +1439,33 @@ proc linewidth {id} {
1439 return $wid
1440 }
1441
1442 +proc rowranges {id} {
1443 + global idrowranges commitrow numcommits rowrangelist
1444 +
1445 + set ranges {}
1446 + if {[info exists commitrow($id)] && $commitrow($id) < $numcommits} {
1447 + set ranges [lindex $rowrangelist $commitrow($id)]
1448 + } elseif {[info exists idrowranges($id)]} {
1449 + set ranges $idrowranges($id)
1450 + }
1451 + return $ranges
1452 +}
1453 +
1454 proc drawlineseg {id i} {
1244 - global rowoffsets rowidlist idrowranges
1455 + global rowoffsets rowidlist
1456 global displayorder
1457 global canv colormap linespc
1458 + global numcommits commitrow
1459
1248 - set startrow [lindex $idrowranges($id) [expr {2 * $i}]]
1249 - set row [lindex $idrowranges($id) [expr {2 * $i + 1}]]
1460 + set ranges [rowranges $id]
1461 + set downarrow 1
1462 + if {[info exists commitrow($id)] && $commitrow($id) < $numcommits} {
1463 + set downarrow [expr {$i < [llength $ranges] / 2 - 1}]
1464 + } else {
1465 + set downarrow 1
1466 + }
1467 + set startrow [lindex $ranges [expr {2 * $i}]]
1468 + set row [lindex $ranges [expr {2 * $i + 1}]]
1469 if {$startrow == $row} return
1470 assigncolor $id
1471 set coords {}
@@ -1290,8 +1509,7 @@ proc drawlineseg {id i} {
1509 }
1510 }
1511 if {[llength $coords] < 4} return
1293 - set last [expr {[llength $idrowranges($id)] / 2 - 1}]
1294 - if {$i < $last} {
1512 + if {$downarrow} {
1513 # This line has an arrow at the lower end: check if the arrow is
1514 # on a diagonal segment, and if so, work around the Tk 8.4
1515 # refusal to draw arrows on diagonal lines.
@@ -1311,7 +1529,7 @@ proc drawlineseg {id i} {
1529 }
1530 }
1531 }
1314 - set arrow [expr {2 * ($i > 0) + ($i < $last)}]
1532 + set arrow [expr {2 * ($i > 0) + $downarrow}]
1533 set arrow [lindex {none first last both} $arrow]
1534 set t [$canv create line $coords -width [linewidth $id] \
1535 -fill $colormap($id) -tags lines.$id -arrow $arrow]
@@ -1320,7 +1538,7 @@ proc drawlineseg {id i} {
1538 }
1539
1540 proc drawparentlinks {id row col olds} {
1323 - global rowidlist canv colormap idrowranges
1541 + global rowidlist canv colormap
1542
1543 set row2 [expr {$row + 1}]
1544 set x [xc $row $col]
@@ -1339,9 +1557,9 @@ proc drawparentlinks {id row col olds} {
1557 if {$x2 > $rmx} {
1558 set rmx $x2
1559 }
1342 - if {[info exists idrowranges($p)] &&
1343 - $row2 == [lindex $idrowranges($p) 0] &&
1344 - $row2 < [lindex $idrowranges($p) 1]} {
1560 + set ranges [rowranges $p]
1561 + if {$ranges ne {} && $row2 == [lindex $ranges 0]
1562 + && $row2 < [lindex $ranges 1]} {
1563 # drawlineseg will do this one for us
1564 continue
1565 }
@@ -1364,11 +1582,11 @@ proc drawparentlinks {id row col olds} {
1582
1583 proc drawlines {id} {
1584 global colormap canv
1367 - global idrowranges idrangedrawn
1585 + global idrangedrawn
1586 global childlist iddrawn commitrow rowidlist
1587
1588 $canv delete lines.$id
1371 - set nr [expr {[llength $idrowranges($id)] / 2}]
1589 + set nr [expr {[llength [rowranges $id]] / 2}]
1590 for {set i 0} {$i < $nr} {incr i} {
1591 if {[info exists idrangedrawn($id,$i)]} {
1592 drawlineseg $id $i
@@ -1431,14 +1649,13 @@ proc drawcmittext {id row col rmx} {
1649
1650 proc drawcmitrow {row} {
1651 global displayorder rowidlist
1434 - global idrowranges idrangedrawn iddrawn
1652 + global idrangedrawn iddrawn
1653 global commitinfo commitlisted parentlist numcommits
1654
1655 if {$row >= $numcommits} return
1656 foreach id [lindex $rowidlist $row] {
1439 - if {![info exists idrowranges($id)]} continue
1657 set i -1
1441 - foreach {s e} $idrowranges($id) {
1658 + foreach {s e} [rowranges $id] {
1659 incr i
1660 if {$row < $s} continue
1661 if {$e eq {}} break
@@ -1507,10 +1724,50 @@ proc clear_display {} {
1724 catch {unset idrangedrawn}
1725 }
1726
1727 +proc findcrossings {id} {
1728 + global rowidlist parentlist numcommits rowoffsets displayorder
1729 +
1730 + set cross {}
1731 + set ccross {}
1732 + foreach {s e} [rowranges $id] {
1733 + if {$e >= $numcommits} {
1734 + set e [expr {$numcommits - 1}]
1735 + if {$e < $s} continue
1736 + }
1737 + set x [lsearch -exact [lindex $rowidlist $e] $id]
1738 + if {$x < 0} {
1739 + puts "findcrossings: oops, no [shortids $id] in row $e"
1740 + continue
1741 + }
1742 + for {set row $e} {[incr row -1] >= $s} {} {
1743 + set olds [lindex $parentlist $row]
1744 + set kid [lindex $displayorder $row]
1745 + set kidx [lsearch -exact [lindex $rowidlist $row] $kid]
1746 + if {$kidx < 0} continue
1747 + set nextrow [lindex $rowidlist [expr {$row + 1}]]
1748 + foreach p $olds {
1749 + set px [lsearch -exact $nextrow $p]
1750 + if {$px < 0} continue
1751 + if {($kidx < $x && $x < $px) || ($px < $x && $x < $kidx)} {
1752 + if {[lsearch -exact $ccross $p] >= 0} continue
1753 + if {$x == $px + ($kidx < $px? -1: 1)} {
1754 + lappend ccross $p
1755 + } elseif {[lsearch -exact $cross $p] < 0} {
1756 + lappend cross $p
1757 + }
1758 + }
1759 + }
1760 + set inc [lindex $rowoffsets $row $x]
1761 + if {$inc eq {}} break
1762 + incr x $inc
1763 + }
1764 + }
1765 + return [concat $ccross {{}} $cross]
1766 +}
1767 +
1768 proc assigncolor {id} {
1769 global colormap colors nextcolor
1770 global commitrow parentlist children childlist
1513 - global cornercrossings crossings
1771
1772 if {[info exists colormap($id)]} return
1773 set ncolors [llength $colors]
@@ -1530,32 +1787,22 @@ proc assigncolor {id} {
1787 }
1788 }
1789 set badcolors {}
1533 - if {[info exists cornercrossings($id)]} {
1534 - foreach x $cornercrossings($id) {
1535 - if {[info exists colormap($x)]
1536 - && [lsearch -exact $badcolors $colormap($x)] < 0} {
1537 - lappend badcolors $colormap($x)
1538 - }
1790 + set origbad {}
1791 + foreach x [findcrossings $id] {
1792 + if {$x eq {}} {
1793 + # delimiter between corner crossings and other crossings
1794 + if {[llength $badcolors] >= $ncolors - 1} break
1795 + set origbad $badcolors
1796 }
1540 - if {[llength $badcolors] >= $ncolors} {
1541 - set badcolors {}
1797 + if {[info exists colormap($x)]
1798 + && [lsearch -exact $badcolors $colormap($x)] < 0} {
1799 + lappend badcolors $colormap($x)
1800 }
1801 }
1544 - set origbad $badcolors
1545 - if {[llength $badcolors] < $ncolors - 1} {
1546 - if {[info exists crossings($id)]} {
1547 - foreach x $crossings($id) {
1548 - if {[info exists colormap($x)]
1549 - && [lsearch -exact $badcolors $colormap($x)] < 0} {
1550 - lappend badcolors $colormap($x)
1551 - }
1552 - }
1553 - if {[llength $badcolors] >= $ncolors} {
1554 - set badcolors $origbad
1555 - }
1556 - }
1557 - set origbad $badcolors
1802 + if {[llength $badcolors] >= $ncolors} {
1803 + set badcolors $origbad
1804 }
1805 + set origbad $badcolors
1806 if {[llength $badcolors] < $ncolors - 1} {
1807 foreach child $kids {
1808 if {[info exists colormap($child)]
@@ -1659,55 +1906,6 @@ proc drawtags {id x xt y1} {
1906 return $xt
1907 }
1908
1662 -proc checkcrossings {row endrow} {
1663 - global displayorder parentlist rowidlist
1664 -
1665 - for {} {$row < $endrow} {incr row} {
1666 - set id [lindex $displayorder $row]
1667 - set i [lsearch -exact [lindex $rowidlist $row] $id]
1668 - if {$i < 0} continue
1669 - set idlist [lindex $rowidlist [expr {$row+1}]]
1670 - foreach p [lindex $parentlist $row] {
1671 - set j [lsearch -exact $idlist $p]
1672 - if {$j > 0} {
1673 - if {$j < $i - 1} {
1674 - notecrossings $row $p $j $i [expr {$j+1}]
1675 - } elseif {$j > $i + 1} {
1676 - notecrossings $row $p $i $j [expr {$j-1}]
1677 - }
1678 - }
1679 - }
1680 - }
1681 -}
1682 -
1683 -proc notecrossings {row id lo hi corner} {
1684 - global rowidlist crossings cornercrossings
1685 -
1686 - for {set i $lo} {[incr i] < $hi} {} {
1687 - set p [lindex [lindex $rowidlist $row] $i]
1688 - if {$p == {}} continue
1689 - if {$i == $corner} {
1690 - if {![info exists cornercrossings($id)]
1691 - || [lsearch -exact $cornercrossings($id) $p] < 0} {
1692 - lappend cornercrossings($id) $p
1693 - }
1694 - if {![info exists cornercrossings($p)]
1695 - || [lsearch -exact $cornercrossings($p) $id] < 0} {
1696 - lappend cornercrossings($p) $id
1697 - }
1698 - } else {
1699 - if {![info exists crossings($id)]
1700 - || [lsearch -exact $crossings($id) $p] < 0} {
1701 - lappend crossings($id) $p
1702 - }
1703 - if {![info exists crossings($p)]
1704 - || [lsearch -exact $crossings($p) $id] < 0} {
1705 - lappend crossings($p) $id
1706 - }
1707 - }
1708 - }
1709 -}
1710 -
1909 proc xcoord {i level ln} {
1910 global canvx0 xspc1 xspc2
1911
@@ -1763,7 +1961,7 @@ proc drawrest {} {
1961 showstuff $commitidx
1962
1963 set drawmsecs [expr {[clock clicks -milliseconds] - $startmsecs}]
1766 - puts "overall $drawmsecs ms for $numcommits commits"
1964 + #puts "overall $drawmsecs ms for $numcommits commits"
1965 }
1966
1967 proc findmatches {f} {
@@ -2433,9 +2631,10 @@ proc selnextline {dir} {
2631 }
2632
2633 proc unselectline {} {
2436 - global selectedline
2634 + global selectedline currentid
2635
2636 catch {unset selectedline}
2637 + catch {unset currentid}
2638 allcanvs delete secsel
2639 }
2640
@@ -2948,12 +3147,13 @@ proc linehover {} {
3147 }
3148
3149 proc clickisonarrow {id y} {
2951 - global lthickness idrowranges
3150 + global lthickness
3151
3152 + set ranges [rowranges $id]
3153 set thresh [expr {2 * $lthickness + 6}]
2954 - set n [expr {[llength $idrowranges($id)] - 1}]
3154 + set n [expr {[llength $ranges] - 1}]
3155 for {set i 1} {$i < $n} {incr i} {
2956 - set row [lindex $idrowranges($id) $i]
3156 + set row [lindex $ranges $i]
3157 if {abs([yc $row] - $y) < $thresh} {
3158 return $i
3159 }
@@ -2962,11 +3162,11 @@ proc clickisonarrow {id y} {
3162 }
3163
3164 proc arrowjump {id n y} {
2965 - global idrowranges canv
3165 + global canv
3166
3167 # 1 <-> 2, 3 <-> 4, etc...
3168 set n [expr {(($n - 1) ^ 1) + 1}]
2969 - set row [lindex $idrowranges($id) $n]
3169 + set row [lindex [rowranges $id] $n]
3170 set yt [yc $row]
3171 set ymax [lindex [$canv cget -scrollregion] 3]
3172 if {$ymax eq {} || $ymax <= 0} return
@@ -3819,10 +4019,26 @@ set historyindex 0
4019
4020 set optim_delay 16
4021
4022 +set nextviewnum 1
4023 +set curview 0
4024 +set viewfiles(0) {}
4025 +
4026 set stopped 0
4027 set stuffsaved 0
4028 set patchnum 0
4029 setcoords
4030 makewindow $revtreeargs
4031 readrefs
3828 -getcommits $revtreeargs
4032 +parse_args $revtreeargs
4033 +set args $parsed_args
4034 +if {$cmdline_files ne {}} {
4035 + # create a view for the files/dirs specified on the command line
4036 + set curview 1
4037 + set nextviewnum 2
4038 + set viewname(1) "Command line"
4039 + set viewfiles(1) $cmdline_files
4040 + .bar.view add command -label $viewname(1) -command {showview 1}
4041 + .bar.view entryconf 2 -state normal
4042 + set args [concat $args "--" $cmdline_files]
4043 +}
4044 +getcommits $args