gitk: Implement a user-friendly Edit View dialog
Originally gitk required the user to specify all limiting options manually in the same field with the list of commits. It is rather unfriendly for new users, who may not know which options can be used, or, indeed, that it is possible to specify them at all. This commit modifies the dialog to present the most useful options as individual fields. Note that options that may be useful to an extent, but produce a severely broken view, are deliberately not included. It is still possible to specify options in the commit list field, but when the dialog is reopened, they will be extracted into their own separate fields. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>maint
parent
887a791f11
commit
218a900bd8
203
gitk
203
gitk
|
@ -3467,8 +3467,8 @@ proc shellsplit {str} {
|
||||||
# Code to implement multiple views
|
# Code to implement multiple views
|
||||||
|
|
||||||
proc newview {ishighlight} {
|
proc newview {ishighlight} {
|
||||||
global nextviewnum newviewname newviewperm newishighlight
|
global nextviewnum newviewname newishighlight
|
||||||
global newviewargs revtreeargs viewargscmd newviewargscmd curview
|
global revtreeargs viewargscmd newviewopts curview
|
||||||
|
|
||||||
set newishighlight $ishighlight
|
set newishighlight $ishighlight
|
||||||
set top .gitkview
|
set top .gitkview
|
||||||
|
@ -3477,59 +3477,173 @@ proc newview {ishighlight} {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
set newviewname($nextviewnum) "[mc "View"] $nextviewnum"
|
set newviewname($nextviewnum) "[mc "View"] $nextviewnum"
|
||||||
set newviewperm($nextviewnum) 0
|
set newviewopts($nextviewnum,perm) 0
|
||||||
set newviewargs($nextviewnum) [shellarglist $revtreeargs]
|
set newviewopts($nextviewnum,cmd) $viewargscmd($curview)
|
||||||
set newviewargscmd($nextviewnum) $viewargscmd($curview)
|
decode_view_opts $nextviewnum $revtreeargs
|
||||||
vieweditor $top $nextviewnum [mc "Gitk view definition"]
|
vieweditor $top $nextviewnum [mc "Gitk view definition"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set known_view_options {
|
||||||
|
{perm b . {} {mc "Remember this view"}}
|
||||||
|
{args t50= + {} {mc "Commits to include (arguments to git log):"}}
|
||||||
|
{all b * "--all" {mc "Use all refs"}}
|
||||||
|
{dorder b . {"--date-order" "-d"} {mc "Strictly sort by date"}}
|
||||||
|
{lright b . "--left-right" {mc "Mark branch sides"}}
|
||||||
|
{since t15 + {"--since=*" "--after=*"} {mc "Since date:"}}
|
||||||
|
{until t15 . {"--until=*" "--before=*"} {mc "Until date:"}}
|
||||||
|
{limit t10 + "--max-count=*" {mc "Max count:"}}
|
||||||
|
{skip t10 . "--skip=*" {mc "Skip:"}}
|
||||||
|
{first b . "--first-parent" {mc "Limit to first parent"}}
|
||||||
|
{cmd t50= + {} {mc "Command to generate more commits to include:"}}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc encode_view_opts {n} {
|
||||||
|
global known_view_options newviewopts
|
||||||
|
|
||||||
|
set rargs [list]
|
||||||
|
foreach opt $known_view_options {
|
||||||
|
set patterns [lindex $opt 3]
|
||||||
|
if {$patterns eq {}} continue
|
||||||
|
set pattern [lindex $patterns 0]
|
||||||
|
|
||||||
|
set val $newviewopts($n,[lindex $opt 0])
|
||||||
|
|
||||||
|
if {[lindex $opt 1] eq "b"} {
|
||||||
|
if {$val} {
|
||||||
|
lappend rargs $pattern
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set val [string trim $val]
|
||||||
|
if {$val ne {}} {
|
||||||
|
set pfix [string range $pattern 0 end-1]
|
||||||
|
lappend rargs $pfix$val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [concat $rargs [shellsplit $newviewopts($n,args)]]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc decode_view_opts {n view_args} {
|
||||||
|
global known_view_options newviewopts
|
||||||
|
|
||||||
|
foreach opt $known_view_options {
|
||||||
|
if {[lindex $opt 1] eq "b"} {
|
||||||
|
set val 0
|
||||||
|
} else {
|
||||||
|
set val {}
|
||||||
|
}
|
||||||
|
set newviewopts($n,[lindex $opt 0]) $val
|
||||||
|
}
|
||||||
|
set oargs [list]
|
||||||
|
foreach arg $view_args {
|
||||||
|
if {[regexp -- {^-([0-9]+)$} $arg arg cnt]
|
||||||
|
&& ![info exists found(limit)]} {
|
||||||
|
set newviewopts($n,limit) $cnt
|
||||||
|
set found(limit) 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
catch { unset val }
|
||||||
|
foreach opt $known_view_options {
|
||||||
|
set id [lindex $opt 0]
|
||||||
|
if {[info exists found($id)]} continue
|
||||||
|
foreach pattern [lindex $opt 3] {
|
||||||
|
if {![string match $pattern $arg]} continue
|
||||||
|
if {[lindex $opt 1] ne "b"} {
|
||||||
|
set size [string length $pattern]
|
||||||
|
set val [string range $arg [expr {$size-1}] end]
|
||||||
|
} else {
|
||||||
|
set val 1
|
||||||
|
}
|
||||||
|
set newviewopts($n,$id) $val
|
||||||
|
set found($id) 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if {[info exists val]} break
|
||||||
|
}
|
||||||
|
if {[info exists val]} continue
|
||||||
|
lappend oargs $arg
|
||||||
|
}
|
||||||
|
set newviewopts($n,args) [shellarglist $oargs]
|
||||||
|
}
|
||||||
|
|
||||||
proc editview {} {
|
proc editview {} {
|
||||||
global curview
|
global curview
|
||||||
global viewname viewperm newviewname newviewperm
|
global viewname viewperm newviewname newviewopts
|
||||||
global viewargs newviewargs viewargscmd newviewargscmd
|
global viewargs viewargscmd
|
||||||
|
|
||||||
set top .gitkvedit-$curview
|
set top .gitkvedit-$curview
|
||||||
if {[winfo exists $top]} {
|
if {[winfo exists $top]} {
|
||||||
raise $top
|
raise $top
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
set newviewname($curview) $viewname($curview)
|
set newviewname($curview) $viewname($curview)
|
||||||
set newviewperm($curview) $viewperm($curview)
|
set newviewopts($curview,perm) $viewperm($curview)
|
||||||
set newviewargs($curview) [shellarglist $viewargs($curview)]
|
set newviewopts($curview,cmd) $viewargscmd($curview)
|
||||||
set newviewargscmd($curview) $viewargscmd($curview)
|
decode_view_opts $curview $viewargs($curview)
|
||||||
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
|
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
|
||||||
}
|
}
|
||||||
|
|
||||||
proc vieweditor {top n title} {
|
proc vieweditor {top n title} {
|
||||||
global newviewname newviewperm viewfiles bgcolor
|
global newviewname newviewopts viewfiles bgcolor
|
||||||
|
global known_view_options
|
||||||
|
|
||||||
toplevel $top
|
toplevel $top
|
||||||
wm title $top $title
|
wm title $top $title
|
||||||
wm transient $top .
|
wm transient $top .
|
||||||
|
|
||||||
|
# View name
|
||||||
|
frame $top.nfr
|
||||||
label $top.nl -text [mc "Name"]
|
label $top.nl -text [mc "Name"]
|
||||||
entry $top.name -width 20 -textvariable newviewname($n)
|
entry $top.name -width 20 -textvariable newviewname($n)
|
||||||
grid $top.nl $top.name -sticky w -pady 5
|
pack $top.nfr -in $top -fill x -pady 5 -padx 3
|
||||||
checkbutton $top.perm -text [mc "Remember this view"] \
|
pack $top.nl -in $top.nfr -side left -padx {0 30}
|
||||||
-variable newviewperm($n)
|
pack $top.name -in $top.nfr -side left
|
||||||
grid $top.perm - -pady 5 -sticky w
|
|
||||||
message $top.al -aspect 1000 \
|
|
||||||
-text [mc "Commits to include (arguments to git log):"]
|
|
||||||
grid $top.al - -sticky w -pady 5
|
|
||||||
entry $top.args -width 50 -textvariable newviewargs($n) \
|
|
||||||
-background $bgcolor
|
|
||||||
grid $top.args - -sticky ew -padx 5
|
|
||||||
|
|
||||||
message $top.ac -aspect 1000 \
|
# View options
|
||||||
-text [mc "Command to generate more commits to include:"]
|
set cframe $top.nfr
|
||||||
grid $top.ac - -sticky w -pady 5
|
set cexpand 0
|
||||||
entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \
|
set cnt 0
|
||||||
-background white
|
foreach opt $known_view_options {
|
||||||
grid $top.argscmd - -sticky ew -padx 5
|
set id [lindex $opt 0]
|
||||||
|
set type [lindex $opt 1]
|
||||||
|
set flags [lindex $opt 2]
|
||||||
|
set title [eval [lindex $opt 4]]
|
||||||
|
set lxpad 0
|
||||||
|
|
||||||
message $top.l -aspect 1000 \
|
if {$flags eq "+" || $flags eq "*"} {
|
||||||
|
set cframe $top.fr$cnt
|
||||||
|
incr cnt
|
||||||
|
frame $cframe
|
||||||
|
pack $cframe -in $top -fill x -pady 3 -padx 3
|
||||||
|
set cexpand [expr {$flags eq "*"}]
|
||||||
|
} else {
|
||||||
|
set lxpad 5
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$type eq "b"} {
|
||||||
|
checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
|
||||||
|
pack $cframe.c_$id -in $cframe -side left \
|
||||||
|
-padx [list $lxpad 0] -expand $cexpand -anchor w
|
||||||
|
} elseif {[regexp {^t(\d+)$} $type type sz]} {
|
||||||
|
message $cframe.l_$id -aspect 1500 -text $title
|
||||||
|
entry $cframe.e_$id -width $sz -background $bgcolor \
|
||||||
|
-textvariable newviewopts($n,$id)
|
||||||
|
pack $cframe.l_$id -in $cframe -side left -padx [list $lxpad 0]
|
||||||
|
pack $cframe.e_$id -in $cframe -side left -expand 1 -fill x
|
||||||
|
} elseif {[regexp {^t(\d+)=$} $type type sz]} {
|
||||||
|
message $cframe.l_$id -aspect 1500 -text $title
|
||||||
|
entry $cframe.e_$id -width $sz -background $bgcolor \
|
||||||
|
-textvariable newviewopts($n,$id)
|
||||||
|
pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w
|
||||||
|
pack $cframe.e_$id -in $cframe -side top -fill x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Path list
|
||||||
|
message $top.l -aspect 1500 \
|
||||||
-text [mc "Enter files and directories to include, one per line:"]
|
-text [mc "Enter files and directories to include, one per line:"]
|
||||||
grid $top.l - -sticky w
|
pack $top.l -in $top -side top -pady [list 7 0] -anchor w -padx 3
|
||||||
text $top.t -width 40 -height 10 -background $bgcolor -font uifont
|
text $top.t -width 40 -height 5 -background $bgcolor -font uifont
|
||||||
if {[info exists viewfiles($n)]} {
|
if {[info exists viewfiles($n)]} {
|
||||||
foreach f $viewfiles($n) {
|
foreach f $viewfiles($n) {
|
||||||
$top.t insert end $f
|
$top.t insert end $f
|
||||||
|
@ -3538,15 +3652,19 @@ proc vieweditor {top n title} {
|
||||||
$top.t delete {end - 1c} end
|
$top.t delete {end - 1c} end
|
||||||
$top.t mark set insert 0.0
|
$top.t mark set insert 0.0
|
||||||
}
|
}
|
||||||
grid $top.t - -sticky ew -padx 5
|
pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
|
||||||
frame $top.buts
|
frame $top.buts
|
||||||
button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
|
button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
|
||||||
|
button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]
|
||||||
button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
|
button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
|
||||||
|
bind $top <Control-Return> [list newviewok $top $n]
|
||||||
|
bind $top <F5> [list newviewok $top $n 1]
|
||||||
bind $top <Escape> [list destroy $top]
|
bind $top <Escape> [list destroy $top]
|
||||||
grid $top.buts.ok $top.buts.can
|
grid $top.buts.ok $top.buts.apply $top.buts.can
|
||||||
grid columnconfigure $top.buts 0 -weight 1 -uniform a
|
grid columnconfigure $top.buts 0 -weight 1 -uniform a
|
||||||
grid columnconfigure $top.buts 1 -weight 1 -uniform a
|
grid columnconfigure $top.buts 1 -weight 1 -uniform a
|
||||||
grid $top.buts - -pady 10 -sticky ew
|
grid columnconfigure $top.buts 2 -weight 1 -uniform a
|
||||||
|
pack $top.buts -in $top -side top -fill x
|
||||||
focus $top.t
|
focus $top.t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3567,13 +3685,13 @@ proc allviewmenus {n op args} {
|
||||||
# doviewmenu $viewhlmenu 1 [list addvhighlight $n] $op $args
|
# doviewmenu $viewhlmenu 1 [list addvhighlight $n] $op $args
|
||||||
}
|
}
|
||||||
|
|
||||||
proc newviewok {top n} {
|
proc newviewok {top n {apply 0}} {
|
||||||
global nextviewnum newviewperm newviewname newishighlight
|
global nextviewnum newviewperm newviewname newishighlight
|
||||||
global viewname viewfiles viewperm selectedview curview
|
global viewname viewfiles viewperm selectedview curview
|
||||||
global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu
|
global viewargs viewargscmd newviewopts viewhlmenu
|
||||||
|
|
||||||
if {[catch {
|
if {[catch {
|
||||||
set newargs [shellsplit $newviewargs($n)]
|
set newargs [encode_view_opts $n]
|
||||||
} err]} {
|
} err]} {
|
||||||
error_popup "[mc "Error in commit selection arguments:"] $err" $top
|
error_popup "[mc "Error in commit selection arguments:"] $err" $top
|
||||||
return
|
return
|
||||||
|
@ -3589,10 +3707,10 @@ proc newviewok {top n} {
|
||||||
# creating a new view
|
# creating a new view
|
||||||
incr nextviewnum
|
incr nextviewnum
|
||||||
set viewname($n) $newviewname($n)
|
set viewname($n) $newviewname($n)
|
||||||
set viewperm($n) $newviewperm($n)
|
set viewperm($n) $newviewopts($n,perm)
|
||||||
set viewfiles($n) $files
|
set viewfiles($n) $files
|
||||||
set viewargs($n) $newargs
|
set viewargs($n) $newargs
|
||||||
set viewargscmd($n) $newviewargscmd($n)
|
set viewargscmd($n) $newviewopts($n,cmd)
|
||||||
addviewmenu $n
|
addviewmenu $n
|
||||||
if {!$newishighlight} {
|
if {!$newishighlight} {
|
||||||
run showview $n
|
run showview $n
|
||||||
|
@ -3601,7 +3719,7 @@ proc newviewok {top n} {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# editing an existing view
|
# editing an existing view
|
||||||
set viewperm($n) $newviewperm($n)
|
set viewperm($n) $newviewopts($n,perm)
|
||||||
if {$newviewname($n) ne $viewname($n)} {
|
if {$newviewname($n) ne $viewname($n)} {
|
||||||
set viewname($n) $newviewname($n)
|
set viewname($n) $newviewname($n)
|
||||||
doviewmenu .bar.view 5 [list showview $n] \
|
doviewmenu .bar.view 5 [list showview $n] \
|
||||||
|
@ -3610,15 +3728,16 @@ proc newviewok {top n} {
|
||||||
# entryconf [list -label $viewname($n) -value $viewname($n)]
|
# entryconf [list -label $viewname($n) -value $viewname($n)]
|
||||||
}
|
}
|
||||||
if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
|
if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
|
||||||
$newviewargscmd($n) ne $viewargscmd($n)} {
|
$newviewopts($n,cmd) ne $viewargscmd($n)} {
|
||||||
set viewfiles($n) $files
|
set viewfiles($n) $files
|
||||||
set viewargs($n) $newargs
|
set viewargs($n) $newargs
|
||||||
set viewargscmd($n) $newviewargscmd($n)
|
set viewargscmd($n) $newviewopts($n,cmd)
|
||||||
if {$curview == $n} {
|
if {$curview == $n} {
|
||||||
run reloadcommits
|
run reloadcommits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if {$apply} return
|
||||||
catch {destroy $top}
|
catch {destroy $top}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue