@matheusbsbs / matheus-bagliano / commits / 13d40b618a
Fork 0

gitk: Make more options easily accessible from Edit View dialog

Commit 218a900bd8efd0d49f8a0d9491aa4786a998d4f4 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 <newren@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Elijah Newren committed Mar 23, 2009 at 11:57 UTC 13d40b618a78ce236d103ab14272b07305f2f7c9
1 file changed +94 -37
gitk
+94 -37
@@ -3671,17 +3671,35 @@ proc newview {ishighlight} {
3671 }
3672
3673 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:"}}
3703 }
3704
3705 proc encode_view_opts {n} {
@@ -3693,13 +3711,19 @@ proc encode_view_opts {n} {
3711 if {$patterns eq {}} continue
3712 set pattern [lindex $patterns 0]
3713
3696 - set val $newviewopts($n,[lindex $opt 0])
3697 -
3714 if {[lindex $opt 1] eq "b"} {
3715 + set val $newviewopts($n,[lindex $opt 0])
3716 if {$val} {
3717 lappend rargs $pattern
3718 }
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 + }
3725 } else {
3726 + set val $newviewopts($n,[lindex $opt 0])
3727 set val [string trim $val]
3728 if {$val ne {}} {
3729 set pfix [string range $pattern 0 end-1]
@@ -3707,6 +3731,7 @@ proc encode_view_opts {n} {
3731 }
3732 }
3733 }
3734 + set rargs [concat $rargs [shellsplit $newviewopts($n,refs)]]
3735 return [concat $rargs [shellsplit $newviewopts($n,args)]]
3736 }
3737
@@ -3714,14 +3739,22 @@ proc decode_view_opts {n view_args} {
3739 global known_view_options newviewopts
3740
3741 foreach opt $known_view_options {
3742 + set id [lindex $opt 0]
3743 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
3749 set val 0
3750 } else {
3751 + # Text fields
3752 set val {}
3753 }
3722 - set newviewopts($n,[lindex $opt 0]) $val
3754 + set newviewopts($n,$id) $val
3755 }
3756 set oargs [list]
3757 + set refargs [list]
3758 foreach arg $view_args {
3759 if {[regexp -- {^-([0-9]+)$} $arg arg cnt]
3760 && ![info exists found(limit)]} {
@@ -3735,11 +3768,17 @@ proc decode_view_opts {n view_args} {
3768 if {[info exists found($id)]} continue
3769 foreach pattern [lindex $opt 3] {
3770 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
3780 set size [string length $pattern]
3781 set val [string range $arg [expr {$size-1}] end]
3741 - } else {
3742 - set val 1
3782 }
3783 set newviewopts($n,$id) $val
3784 set found($id) 1
@@ -3748,8 +3787,13 @@ proc decode_view_opts {n view_args} {
3787 if {[info exists val]} break
3788 }
3789 if {[info exists val]} continue
3751 - lappend oargs $arg
3790 + if {[regexp {^-} $arg]} {
3791 + lappend oargs $arg
3792 + } else {
3793 + lappend refargs $arg
3794 + }
3795 }
3796 + set newviewopts($n,refs) [shellarglist $refargs]
3797 set newviewopts($n,args) [shellarglist $oargs]
3798 }
3799
@@ -3785,16 +3829,16 @@ proc vieweditor {top n title} {
3829 global known_view_options
3830
3831 toplevel $top
3788 - wm title $top $title
3832 + wm title $top [concat $title "-- criteria for selecting revisions"]
3833 make_transient $top .
3834
3835 # View name
3836 frame $top.nfr
3793 - label $top.nl -text [mc "Name"]
3837 + label $top.nl -text [mc "View Name:"]
3838 entry $top.name -width 20 -textvariable newviewname($n)
3839 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}
3842
3843 # View options
3844 set cframe $top.nfr
@@ -3813,14 +3857,28 @@ proc vieweditor {top n title} {
3857 frame $cframe
3858 pack $cframe -in $top -fill x -pady 3 -padx 3
3859 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 "*."}]
3866 } else {
3867 set lxpad 5
3868 }
3869
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"} {
3874 checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
3875 pack $cframe.c_$id -in $cframe -side left \
3876 -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
3882 } elseif {[regexp {^t(\d+)$} $type type sz]} {
3883 message $cframe.l_$id -aspect 1500 -text $title
3884 entry $cframe.e_$id -width $sz -background $bgcolor \
@@ -3833,23 +3891,22 @@ proc vieweditor {top n title} {
3891 -textvariable newviewopts($n,$id)
3892 pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w
3893 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
3907 }
3908 }
3909
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
3910 frame $top.buts
3911 button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
3912 button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]