}
}
-proc parse_args {rargs} {
- global parsed_args cmdline_files
-
- set parsed_args {}
- set cmdline_files {}
- if {[catch {
- set args [concat --default HEAD $rargs]
- set args [split [eval exec git-rev-parse $args] "\n"]
- set i 0
- foreach arg $args {
- if {![regexp {^[0-9a-f]{40}$} $arg]} {
- if {$arg eq "--"} {
- incr i
- }
- set cmdline_files [lrange $args $i end]
- break
- }
- lappend parsed_args $arg
- incr i
- }
- }]} {
- # if git-rev-parse failed for some reason...
- set i [lsearch -exact $rargs "--"]
- if {$i >= 0} {
- set cmdline_files [lrange $rargs [expr {$i+1}] end]
- set rargs [lrange $rargs 0 [expr {$i-1}]]
- }
- if {$rargs == {}} {
- set parsed_args HEAD
- } else {
- set parsed_args $rargs
- }
- }
-}
-
-proc start_rev_list {rlargs} {
+proc start_rev_list {} {
global startmsecs nextupdate ncmupdate
global commfd leftover tclencoding datemode
+ global revtreeargs curview viewfiles
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr {$startmsecs + 100}]
set ncmupdate 1
initlayout
+ set args $revtreeargs
+ if {$viewfiles($curview) ne {}} {
+ set args [concat $args "--" $viewfiles($curview)]
+ }
set order "--topo-order"
if {$datemode} {
set order "--date-order"
}
if {[catch {
set commfd [open [concat | git-rev-list --header $order \
- --parents --boundary $rlargs] r]
+ --parents --boundary --default HEAD $args] r]
} err]} {
puts stderr "Error executing git-rev-list: $err"
exit 1
unset commfd
}
-proc getcommits {rargs} {
+proc getcommits {} {
global phase canv mainfont
set phase getcommits
- start_rev_list $rargs
+ start_rev_list
$canv delete all
$canv create text 3 3 -anchor nw -text "Reading commits..." \
-font $mainfont -tags textitems
set n $curview
set curview -1
catch {unset viewdata($n)}
- parse_args $revtreeargs
readrefs
showview $n
}
.bar.view add command -label "New view..." -command newview
.bar.view add command -label "Delete view" -command delview -state disabled
.bar.view add separator
- .bar.view add command -label "All files" -command {showview 0}
+ .bar.view add radiobutton -label "All files" -command {showview 0} \
+ -variable selectedview -value 0
menu .bar.help
.bar add cascade -label "Help" -menu .bar.help
.bar.help add command -label "About gitk" -command about
global canv canv2 canv3 ctext cflist mainfont textfont uifont
global stuffsaved findmergefiles maxgraphpct
global maxwidth
+ global viewname viewfiles viewperm nextviewnum
if {$stuffsaved} return
if {![winfo viewable .]} return
set wid [expr {([winfo width $cflist] - 11) \
/ [font measure [$cflist cget -font] "0"]}]
puts $f "set geometry(cflistw) $wid"
+ puts -nonewline $f "set permviews {"
+ for {set v 0} {$v < $nextviewnum} {incr v} {
+ if {$viewperm($v)} {
+ puts $f "{[list $viewname($v) $viewfiles($v)]}"
+ }
+ }
+ puts $f "}"
close $f
file rename -force "~/.gitk-new" "~/.gitk"
}
}
proc newview {} {
- global newviewname nextviewnum newviewtop
+ global newviewname nextviewnum newviewtop newviewperm uifont
set top .gitkview
if {[winfo exists $top]} {
set newviewtop $top
toplevel $top
wm title $top "Gitk view definition"
- label $top.nl -text "Name"
+ label $top.nl -text "Name" -font $uifont
entry $top.name -width 20 -textvariable newviewname
set newviewname "View $nextviewnum"
- grid $top.nl $top.name -sticky w
- label $top.l -text "Files and directories to include:"
- grid $top.l - -sticky w -pady 10
- text $top.t -width 30 -height 10
- grid $top.t - -sticky w
+ grid $top.nl $top.name -sticky w -pady 5
+ set newviewperm 0
+ checkbutton $top.perm -text "Remember this view" -variable newviewperm
+ grid $top.perm - -pady 5 -sticky w
+ message $top.l -aspect 500 -font $uifont \
+ -text "Enter files and directories to include, one per line:"
+ grid $top.l - -sticky w
+ text $top.t -width 40 -height 10 -background white
+ grid $top.t - -sticky w -padx 5
frame $top.buts
button $top.buts.ok -text "OK" -command newviewok
button $top.buts.can -text "Cancel" -command newviewcan
}
proc newviewok {} {
- global newviewtop nextviewnum
- global viewname viewfiles
+ global newviewtop nextviewnum newviewperm
+ global viewname viewfiles viewperm selectedview
set n $nextviewnum
incr nextviewnum
set viewname($n) [$newviewtop.name get]
+ set viewperm($n) $newviewperm
set files {}
foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
set ft [string trim $f]
set viewfiles($n) $files
catch {destroy $newviewtop}
unset newviewtop
- .bar.view add command -label $viewname($n) -command [list showview $n]
+ .bar.view add radiobutton -label $viewname($n) \
+ -command [list showview $n] -variable selectedview -value $n
after idle showview $n
}
}
proc delview {} {
- global curview viewdata
+ global curview viewdata viewperm
if {$curview == 0} return
set nmenu [.bar.view index end]
}
}
set viewdata($curview) {}
+ set viewperm($curview) 0
showview 0
}
global numcommits rowrangelist commitlisted idrowranges
global selectedline currentid canv canvy0
global matchinglines treediffs
- global parsed_args
global pending_select phase
global commitidx rowlaidout rowoptim linesegends leftover
global commfd nextupdate
+ global selectedview
if {$n == $curview} return
set selid {}
clear_display
set curview $n
+ set selectedview $n
.bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
if {![info exists viewdata($n)]} {
- set args $parsed_args
- if {$viewfiles($n) ne {}} {
- set args [concat $args "--" $viewfiles($n)]
- }
set pending_select $selid
- getcommits $args
+ getcommits
return
}
proc addextraid {id row} {
global displayorder commitrow commitinfo
- global commitidx
+ global commitidx commitlisted
global parentlist childlist children
incr commitidx
lappend displayorder $id
+ lappend commitlisted 0
lappend parentlist {}
set commitrow($id) $row
readcommit $id
proc drawcmitrow {row} {
global displayorder rowidlist
global idrangedrawn iddrawn
- global commitinfo commitlisted parentlist numcommits
+ global commitinfo parentlist numcommits
if {$row >= $numcommits} return
foreach id [lindex $rowidlist $row] {
set nextviewnum 1
set curview 0
+set selectedview 0
set viewfiles(0) {}
+set viewperm(0) 0
set stopped 0
set stuffsaved 0
setcoords
makewindow
readrefs
-parse_args $revtreeargs
-set args $parsed_args
+
+set cmdline_files {}
+catch {
+ set fileargs [eval exec git-rev-parse --no-revs --no-flags $revtreeargs]
+ set cmdline_files [split $fileargs "\n"]
+ set n [llength $cmdline_files]
+ set revtreeargs [lrange $revtreeargs 0 end-$n]
+}
+if {[lindex $revtreeargs end] eq "--"} {
+ set revtreeargs [lrange $revtreeargs 0 end-1]
+}
+
if {$cmdline_files ne {}} {
# create a view for the files/dirs specified on the command line
set curview 1
+ set selectedview 1
set nextviewnum 2
set viewname(1) "Command line"
set viewfiles(1) $cmdline_files
- .bar.view add command -label $viewname(1) -command {showview 1}
+ set viewperm(1) 0
+ .bar.view add radiobutton -label $viewname(1) -command {showview 1} \
+ -variable selectedview -value 1
.bar.view entryconf 2 -state normal
- set args [concat $args "--" $cmdline_files]
}
-getcommits $args
+
+if {[info exists permviews]} {
+ foreach v $permviews {
+ set n $nextviewnum
+ incr nextviewnum
+ set viewname($n) [lindex $v 0]
+ set viewfiles($n) [lindex $v 1]
+ set viewperm($n) 1
+ .bar.view add radiobutton -label $viewname($n) \
+ -command [list showview $n] -variable selectedview -value $n
+ }
+}
+getcommits