Skip to content

Commit 13d40b6

Browse files
newrenpaulusmack
authored andcommitted
gitk: Make more options easily accessible from Edit View dialog
Commit 218a900 added a number of new individual fields for the Edit View dialog to make them more accessible to end users, while still allowing all options to be specified in the "arguments to git log" field. This extends the dialog further, to include refs, author, committer, commit message, and patch contents. As before everything still remains accessible from the "arguments to git log" input field. Additionally, this provides hints for the format of the various input fields (for example, listing some sample date strings in different formats), and puts related query items into subsections to make it easier to digest the number of options that exist. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent a813873 commit 13d40b6

File tree

1 file changed

+94
-37
lines changed

1 file changed

+94
-37
lines changed

gitk

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,17 +3671,35 @@ proc newview {ishighlight} {
36713671
}
36723672

36733673
set known_view_options {
3674-
{perm b . {} {mc "Remember this view"}}
3675-
{args t50= + {} {mc "Commits to include (arguments to git log):"}}
3676-
{all b * "--all" {mc "Use all refs"}}
3677-
{dorder b . {"--date-order" "-d"} {mc "Strictly sort by date"}}
3678-
{lright b . "--left-right" {mc "Mark branch sides"}}
3679-
{since t15 + {"--since=*" "--after=*"} {mc "Since date:"}}
3680-
{until t15 . {"--until=*" "--before=*"} {mc "Until date:"}}
3681-
{limit t10 + "--max-count=*" {mc "Max count:"}}
3682-
{skip t10 . "--skip=*" {mc "Skip:"}}
3683-
{first b . "--first-parent" {mc "Limit to first parent"}}
3684-
{cmd t50= + {} {mc "Command to generate more commits to include:"}}
3674+
{perm b . {} {mc "Remember this view"}}
3675+
{reflabel l + {} {mc "References (space separated list):"}}
3676+
{refs t15 .. {} {mc "Branches & tags:"}}
3677+
{allrefs b *. "--all" {mc "All refs"}}
3678+
{branches b . "--branches" {mc "All (local) branches"}}
3679+
{tags b . "--tags" {mc "All tags"}}
3680+
{remotes b . "--remotes" {mc "All remote-tracking branches"}}
3681+
{commitlbl l + {} {mc "Commit Info (regular expressions):"}}
3682+
{author t15 .. "--author=*" {mc "Author:"}}
3683+
{committer t15 . "--committer=*" {mc "Committer:"}}
3684+
{loginfo t15 .. "--grep=*" {mc "Commit Message:"}}
3685+
{allmatch b .. "--all-match" {mc "Matches all Commit Info criteria"}}
3686+
{changes_l l + {} {mc "Changes to Files:"}}
3687+
{pickaxe_s r0 . {} {mc "Fixed String"}}
3688+
{pickaxe_t r1 . "--pickaxe-regex" {mc "Regular Expression"}}
3689+
{pickaxe t15 .. "-S*" {mc "Search string:"}}
3690+
{datelabel l + {} {mc "Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 15:27:38\"):"}}
3691+
{since t15 .. {"--since=*" "--after=*"} {mc "Since:"}}
3692+
{until t15 . {"--until=*" "--before=*"} {mc "Until:"}}
3693+
{limit_lbl l + {} {mc "Limit and/or skip a number of revisions (positive integer):"}}
3694+
{limit t10 *. "--max-count=*" {mc "Number to show:"}}
3695+
{skip t10 . "--skip=*" {mc "Number to skip:"}}
3696+
{misc_lbl l + {} {mc "Miscellaneous options:"}}
3697+
{dorder b *. {"--date-order" "-d"} {mc "Strictly sort by date"}}
3698+
{lright b . "--left-right" {mc "Mark branch sides"}}
3699+
{first b . "--first-parent" {mc "Limit to first parent"}}
3700+
{args t50 *. {} {mc "Additional arguments to git log:"}}
3701+
{allpaths path + {} {mc "Enter files and directories to include, one per line:"}}
3702+
{cmd t50= + {} {mc "Command to generate more commits to include:"}}
36853703
}
36863704

36873705
proc encode_view_opts {n} {
@@ -3693,35 +3711,50 @@ proc encode_view_opts {n} {
36933711
if {$patterns eq {}} continue
36943712
set pattern [lindex $patterns 0]
36953713

3696-
set val $newviewopts($n,[lindex $opt 0])
3697-
36983714
if {[lindex $opt 1] eq "b"} {
3715+
set val $newviewopts($n,[lindex $opt 0])
36993716
if {$val} {
37003717
lappend rargs $pattern
37013718
}
3719+
} elseif {[regexp {^r(\d+)$} [lindex $opt 1] type value]} {
3720+
regexp {^(.*_)} [lindex $opt 0] uselessvar button_id
3721+
set val $newviewopts($n,$button_id)
3722+
if {$val eq $value} {
3723+
lappend rargs $pattern
3724+
}
37023725
} else {
3726+
set val $newviewopts($n,[lindex $opt 0])
37033727
set val [string trim $val]
37043728
if {$val ne {}} {
37053729
set pfix [string range $pattern 0 end-1]
37063730
lappend rargs $pfix$val
37073731
}
37083732
}
37093733
}
3734+
set rargs [concat $rargs [shellsplit $newviewopts($n,refs)]]
37103735
return [concat $rargs [shellsplit $newviewopts($n,args)]]
37113736
}
37123737

37133738
proc decode_view_opts {n view_args} {
37143739
global known_view_options newviewopts
37153740

37163741
foreach opt $known_view_options {
3742+
set id [lindex $opt 0]
37173743
if {[lindex $opt 1] eq "b"} {
3744+
# Checkboxes
3745+
set val 0
3746+
} elseif {[regexp {^r(\d+)$} [lindex $opt 1]]} {
3747+
# Radiobuttons
3748+
regexp {^(.*_)} $id uselessvar id
37183749
set val 0
37193750
} else {
3751+
# Text fields
37203752
set val {}
37213753
}
3722-
set newviewopts($n,[lindex $opt 0]) $val
3754+
set newviewopts($n,$id) $val
37233755
}
37243756
set oargs [list]
3757+
set refargs [list]
37253758
foreach arg $view_args {
37263759
if {[regexp -- {^-([0-9]+)$} $arg arg cnt]
37273760
&& ![info exists found(limit)]} {
@@ -3735,11 +3768,17 @@ proc decode_view_opts {n view_args} {
37353768
if {[info exists found($id)]} continue
37363769
foreach pattern [lindex $opt 3] {
37373770
if {![string match $pattern $arg]} continue
3738-
if {[lindex $opt 1] ne "b"} {
3771+
if {[lindex $opt 1] eq "b"} {
3772+
# Check buttons
3773+
set val 1
3774+
} elseif {[regexp {^r(\d+)$} [lindex $opt 1] match num]} {
3775+
# Radio buttons
3776+
regexp {^(.*_)} $id uselessvar id
3777+
set val $num
3778+
} else {
3779+
# Text input fields
37393780
set size [string length $pattern]
37403781
set val [string range $arg [expr {$size-1}] end]
3741-
} else {
3742-
set val 1
37433782
}
37443783
set newviewopts($n,$id) $val
37453784
set found($id) 1
@@ -3748,8 +3787,13 @@ proc decode_view_opts {n view_args} {
37483787
if {[info exists val]} break
37493788
}
37503789
if {[info exists val]} continue
3751-
lappend oargs $arg
3790+
if {[regexp {^-} $arg]} {
3791+
lappend oargs $arg
3792+
} else {
3793+
lappend refargs $arg
3794+
}
37523795
}
3796+
set newviewopts($n,refs) [shellarglist $refargs]
37533797
set newviewopts($n,args) [shellarglist $oargs]
37543798
}
37553799

@@ -3785,16 +3829,16 @@ proc vieweditor {top n title} {
37853829
global known_view_options
37863830

37873831
toplevel $top
3788-
wm title $top $title
3832+
wm title $top [concat $title "-- criteria for selecting revisions"]
37893833
make_transient $top .
37903834

37913835
# View name
37923836
frame $top.nfr
3793-
label $top.nl -text [mc "Name"]
3837+
label $top.nl -text [mc "View Name:"]
37943838
entry $top.name -width 20 -textvariable newviewname($n)
37953839
pack $top.nfr -in $top -fill x -pady 5 -padx 3
3796-
pack $top.nl -in $top.nfr -side left -padx {0 30}
3797-
pack $top.name -in $top.nfr -side left
3840+
pack $top.nl -in $top.nfr -side left -padx {0 5}
3841+
pack $top.name -in $top.nfr -side left -padx {0 25}
37983842

37993843
# View options
38003844
set cframe $top.nfr
@@ -3813,14 +3857,28 @@ proc vieweditor {top n title} {
38133857
frame $cframe
38143858
pack $cframe -in $top -fill x -pady 3 -padx 3
38153859
set cexpand [expr {$flags eq "*"}]
3860+
} elseif {$flags eq ".." || $flags eq "*."} {
3861+
set cframe $top.fr$cnt
3862+
incr cnt
3863+
frame $cframe
3864+
pack $cframe -in $top -fill x -pady 3 -padx [list 15 3]
3865+
set cexpand [expr {$flags eq "*."}]
38163866
} else {
38173867
set lxpad 5
38183868
}
38193869

3820-
if {$type eq "b"} {
3870+
if {$type eq "l"} {
3871+
label $cframe.l_$id -text $title
3872+
pack $cframe.l_$id -in $cframe -side left -pady [list 3 0] -anchor w
3873+
} elseif {$type eq "b"} {
38213874
checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
38223875
pack $cframe.c_$id -in $cframe -side left \
38233876
-padx [list $lxpad 0] -expand $cexpand -anchor w
3877+
} elseif {[regexp {^r(\d+)$} $type type sz]} {
3878+
regexp {^(.*_)} $id uselessvar button_id
3879+
radiobutton $cframe.c_$id -text $title -variable newviewopts($n,$button_id) -value $sz
3880+
pack $cframe.c_$id -in $cframe -side left \
3881+
-padx [list $lxpad 0] -expand $cexpand -anchor w
38243882
} elseif {[regexp {^t(\d+)$} $type type sz]} {
38253883
message $cframe.l_$id -aspect 1500 -text $title
38263884
entry $cframe.e_$id -width $sz -background $bgcolor \
@@ -3833,23 +3891,22 @@ proc vieweditor {top n title} {
38333891
-textvariable newviewopts($n,$id)
38343892
pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w
38353893
pack $cframe.e_$id -in $cframe -side top -fill x
3894+
} elseif {$type eq "path"} {
3895+
message $top.l -aspect 1500 -text $title
3896+
pack $top.l -in $top -side top -pady [list 3 0] -anchor w -padx 3
3897+
text $top.t -width 40 -height 5 -background $bgcolor -font uifont
3898+
if {[info exists viewfiles($n)]} {
3899+
foreach f $viewfiles($n) {
3900+
$top.t insert end $f
3901+
$top.t insert end "\n"
3902+
}
3903+
$top.t delete {end - 1c} end
3904+
$top.t mark set insert 0.0
3905+
}
3906+
pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
38363907
}
38373908
}
38383909

3839-
# Path list
3840-
message $top.l -aspect 1500 \
3841-
-text [mc "Enter files and directories to include, one per line:"]
3842-
pack $top.l -in $top -side top -pady [list 7 0] -anchor w -padx 3
3843-
text $top.t -width 40 -height 5 -background $bgcolor -font uifont
3844-
if {[info exists viewfiles($n)]} {
3845-
foreach f $viewfiles($n) {
3846-
$top.t insert end $f
3847-
$top.t insert end "\n"
3848-
}
3849-
$top.t delete {end - 1c} end
3850-
$top.t mark set insert 0.0
3851-
}
3852-
pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
38533910
frame $top.buts
38543911
button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
38553912
button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]

0 commit comments

Comments
 (0)