2007-07-04 02:57:18 +00:00
|
|
|
# git-gui revision chooser
|
|
|
|
# Copyright (C) 2006, 2007 Shawn Pearce
|
|
|
|
|
|
|
|
class choose_rev {
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
image create photo ::choose_rev::img_find -data {R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7}
|
|
|
|
|
2007-07-04 02:57:18 +00:00
|
|
|
field w ; # our megawidget path
|
2007-07-04 20:38:13 +00:00
|
|
|
field w_list ; # list of currently filtered specs
|
|
|
|
field w_filter ; # filter entry for $w_list
|
2007-07-04 02:57:18 +00:00
|
|
|
|
|
|
|
field c_expr {}; # current revision expression
|
2010-01-26 00:05:31 +00:00
|
|
|
field filter ""; # current filter string
|
2007-07-04 20:38:13 +00:00
|
|
|
field revtype head; # type of revision chosen
|
|
|
|
field cur_specs [list]; # list of specs for $revtype
|
|
|
|
field spec_head ; # list of all head specs
|
|
|
|
field spec_trck ; # list of all tracking branch specs
|
|
|
|
field spec_tag ; # list of all tag specs
|
2007-07-25 08:13:00 +00:00
|
|
|
field tip_data ; # array of tip commit info by refname
|
2007-07-25 08:20:02 +00:00
|
|
|
field log_last ; # array of reflog date by refname
|
2007-07-04 05:10:41 +00:00
|
|
|
|
2007-07-25 08:13:00 +00:00
|
|
|
field tooltip_wm {} ; # Current tooltip toplevel, if open
|
|
|
|
field tooltip_t {} ; # Text widget in $tooltip_wm
|
|
|
|
field tooltip_timer {} ; # Current timer event for our tooltip
|
|
|
|
|
|
|
|
proc new {path {title {}}} {
|
|
|
|
return [_new $path 0 $title]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc new_unmerged {path {title {}}} {
|
|
|
|
return [_new $path 1 $title]
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor _new {path unmerged_only title} {
|
2010-01-26 00:05:31 +00:00
|
|
|
global current_branch is_detached use_ttk NS
|
2007-07-04 02:57:18 +00:00
|
|
|
|
2007-07-30 01:26:42 +00:00
|
|
|
if {![info exists ::all_remotes]} {
|
|
|
|
load_all_remotes
|
|
|
|
}
|
|
|
|
|
2007-07-04 02:57:18 +00:00
|
|
|
set w $path
|
|
|
|
|
|
|
|
if {$title ne {}} {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::labelframe $w -text $title
|
2007-07-04 02:57:18 +00:00
|
|
|
} else {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w
|
2007-07-04 02:57:18 +00:00
|
|
|
}
|
|
|
|
bind $w <Destroy> [cb _delete %W]
|
|
|
|
|
2007-07-08 22:40:56 +00:00
|
|
|
if {$is_detached} {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::radiobutton $w.detachedhead_r \
|
2007-07-21 12:21:34 +00:00
|
|
|
-text [mc "This Detached Checkout"] \
|
2007-07-08 22:40:56 +00:00
|
|
|
-value HEAD \
|
|
|
|
-variable @revtype
|
2010-01-26 00:05:31 +00:00
|
|
|
if {!$use_ttk} {$w.detachedhead_r configure -anchor w}
|
2007-07-08 22:40:56 +00:00
|
|
|
grid $w.detachedhead_r -sticky we -padx {0 5} -columnspan 2
|
|
|
|
}
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::radiobutton $w.expr_r \
|
2007-07-21 12:21:34 +00:00
|
|
|
-text [mc "Revision Expression:"] \
|
2007-07-04 02:57:18 +00:00
|
|
|
-value expr \
|
|
|
|
-variable @revtype
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::entry $w.expr_t \
|
2007-07-04 02:57:18 +00:00
|
|
|
-width 50 \
|
|
|
|
-textvariable @c_expr \
|
|
|
|
-validate key \
|
|
|
|
-validatecommand [cb _validate %d %S]
|
|
|
|
grid $w.expr_r $w.expr_t -sticky we -padx {0 5}
|
2007-07-04 20:38:13 +00:00
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.types
|
|
|
|
${NS}::radiobutton $w.types.head_r \
|
2007-07-21 12:21:34 +00:00
|
|
|
-text [mc "Local Branch"] \
|
2007-07-04 20:38:13 +00:00
|
|
|
-value head \
|
|
|
|
-variable @revtype
|
|
|
|
pack $w.types.head_r -side left
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::radiobutton $w.types.trck_r \
|
2007-07-21 12:21:34 +00:00
|
|
|
-text [mc "Tracking Branch"] \
|
2007-07-04 20:38:13 +00:00
|
|
|
-value trck \
|
|
|
|
-variable @revtype
|
|
|
|
pack $w.types.trck_r -side left
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::radiobutton $w.types.tag_r \
|
2007-07-21 12:21:34 +00:00
|
|
|
-text [mc "Tag"] \
|
2007-07-04 20:38:13 +00:00
|
|
|
-value tag \
|
|
|
|
-variable @revtype
|
|
|
|
pack $w.types.tag_r -side left
|
|
|
|
set w_filter $w.types.filter
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::entry $w_filter \
|
2007-07-04 20:38:13 +00:00
|
|
|
-width 12 \
|
|
|
|
-textvariable @filter \
|
|
|
|
-validate key \
|
|
|
|
-validatecommand [cb _filter %P]
|
|
|
|
pack $w_filter -side right
|
2010-01-26 00:05:31 +00:00
|
|
|
pack [${NS}::label $w.types.filter_icon \
|
2007-07-04 20:38:13 +00:00
|
|
|
-image ::choose_rev::img_find \
|
|
|
|
] -side right
|
|
|
|
grid $w.types -sticky we -padx {0 5} -columnspan 2
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
if {$use_ttk} {
|
|
|
|
ttk::frame $w.list -style SListbox.TFrame -padding 2
|
|
|
|
} else {
|
|
|
|
frame $w.list
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
set w_list $w.list.l
|
|
|
|
listbox $w_list \
|
|
|
|
-font font_diff \
|
|
|
|
-width 50 \
|
2007-07-18 06:27:39 +00:00
|
|
|
-height 10 \
|
2007-07-04 20:38:13 +00:00
|
|
|
-selectmode browse \
|
|
|
|
-exportselection false \
|
|
|
|
-xscrollcommand [cb _sb_set $w.list.sbx h] \
|
|
|
|
-yscrollcommand [cb _sb_set $w.list.sby v]
|
2010-01-26 00:05:31 +00:00
|
|
|
if {$use_ttk} {
|
|
|
|
$w_list configure -relief flat -highlightthickness 0 -borderwidth 0
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
pack $w_list -fill both -expand 1
|
|
|
|
grid $w.list -sticky nswe -padx {20 5} -columnspan 2
|
2007-07-25 08:13:00 +00:00
|
|
|
bind $w_list <Any-Motion> [cb _show_tooltip @%x,%y]
|
|
|
|
bind $w_list <Any-Enter> [cb _hide_tooltip]
|
|
|
|
bind $w_list <Any-Leave> [cb _hide_tooltip]
|
|
|
|
bind $w_list <Destroy> [cb _hide_tooltip]
|
2007-07-04 02:57:18 +00:00
|
|
|
|
|
|
|
grid columnconfigure $w 1 -weight 1
|
2007-07-08 22:40:56 +00:00
|
|
|
if {$is_detached} {
|
|
|
|
grid rowconfigure $w 3 -weight 1
|
|
|
|
} else {
|
|
|
|
grid rowconfigure $w 2 -weight 1
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
|
|
|
|
trace add variable @revtype write [cb _select]
|
|
|
|
bind $w_filter <Key-Return> [list focus $w_list]\;break
|
|
|
|
bind $w_filter <Key-Down> [list focus $w_list]
|
|
|
|
|
2007-07-25 08:13:00 +00:00
|
|
|
set fmt list
|
|
|
|
append fmt { %(refname)}
|
|
|
|
append fmt { [list}
|
|
|
|
append fmt { %(objecttype)}
|
|
|
|
append fmt { %(objectname)}
|
|
|
|
append fmt { [concat %(taggername) %(authorname)]}
|
2007-09-10 05:54:16 +00:00
|
|
|
append fmt { [reformat_date [concat %(taggerdate) %(authordate)]]}
|
2007-07-25 08:13:00 +00:00
|
|
|
append fmt { %(subject)}
|
|
|
|
append fmt {] [list}
|
|
|
|
append fmt { %(*objecttype)}
|
|
|
|
append fmt { %(*objectname)}
|
|
|
|
append fmt { %(*authorname)}
|
2007-09-10 05:54:16 +00:00
|
|
|
append fmt { [reformat_date %(*authordate)]}
|
2007-07-25 08:13:00 +00:00
|
|
|
append fmt { %(*subject)}
|
|
|
|
append fmt {]}
|
|
|
|
set all_refn [list]
|
|
|
|
set fr_fd [git_read for-each-ref \
|
|
|
|
--tcl \
|
|
|
|
--sort=-taggerdate \
|
|
|
|
--format=$fmt \
|
|
|
|
refs/heads \
|
|
|
|
refs/remotes \
|
|
|
|
refs/tags \
|
|
|
|
]
|
|
|
|
fconfigure $fr_fd -translation lf -encoding utf-8
|
|
|
|
while {[gets $fr_fd line] > 0} {
|
|
|
|
set line [eval $line]
|
|
|
|
if {[lindex $line 1 0] eq {tag}} {
|
|
|
|
if {[lindex $line 2 0] eq {commit}} {
|
|
|
|
set sha1 [lindex $line 2 1]
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
} elseif {[lindex $line 1 0] eq {commit}} {
|
|
|
|
set sha1 [lindex $line 1 1]
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
set refn [lindex $line 0]
|
|
|
|
set tip_data($refn) [lrange $line 1 end]
|
|
|
|
lappend cmt_refn($sha1) $refn
|
|
|
|
lappend all_refn $refn
|
|
|
|
}
|
|
|
|
close $fr_fd
|
|
|
|
|
|
|
|
if {$unmerged_only} {
|
|
|
|
set fr_fd [git_read rev-list --all ^$::HEAD]
|
|
|
|
while {[gets $fr_fd sha1] > 0} {
|
|
|
|
if {[catch {set rlst $cmt_refn($sha1)}]} continue
|
|
|
|
foreach refn $rlst {
|
|
|
|
set inc($refn) 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close $fr_fd
|
|
|
|
} else {
|
|
|
|
foreach refn $all_refn {
|
|
|
|
set inc($refn) 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
set spec_head [list]
|
2007-07-08 22:40:56 +00:00
|
|
|
foreach name [load_all_heads] {
|
2007-07-25 08:13:00 +00:00
|
|
|
set refn refs/heads/$name
|
|
|
|
if {[info exists inc($refn)]} {
|
|
|
|
lappend spec_head [list $name $refn]
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set spec_trck [list]
|
|
|
|
foreach spec [all_tracking_branches] {
|
2007-07-25 08:13:00 +00:00
|
|
|
set refn [lindex $spec 0]
|
|
|
|
if {[info exists inc($refn)]} {
|
|
|
|
regsub ^refs/(heads|remotes)/ $refn {} name
|
|
|
|
lappend spec_trck [concat $name $spec]
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set spec_tag [list]
|
|
|
|
foreach name [load_all_tags] {
|
2007-07-25 08:13:00 +00:00
|
|
|
set refn refs/tags/$name
|
|
|
|
if {[info exists inc($refn)]} {
|
|
|
|
lappend spec_tag [list $name $refn]
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-08 22:40:56 +00:00
|
|
|
if {$is_detached} { set revtype HEAD
|
|
|
|
} elseif {[llength $spec_head] > 0} { set revtype head
|
2007-07-04 20:38:13 +00:00
|
|
|
} elseif {[llength $spec_trck] > 0} { set revtype trck
|
|
|
|
} elseif {[llength $spec_tag ] > 0} { set revtype tag
|
|
|
|
} else { set revtype expr
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$revtype eq {head} && $current_branch ne {}} {
|
|
|
|
set i 0
|
|
|
|
foreach spec $spec_head {
|
|
|
|
if {[lindex $spec 0] eq $current_branch} {
|
2007-07-09 01:29:54 +00:00
|
|
|
$w_list selection clear 0 end
|
2007-07-04 20:38:13 +00:00
|
|
|
$w_list selection set $i
|
|
|
|
break
|
|
|
|
}
|
|
|
|
incr i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 02:57:18 +00:00
|
|
|
return $this
|
|
|
|
}
|
|
|
|
|
2007-07-04 03:33:59 +00:00
|
|
|
method none {text} {
|
2010-01-26 00:05:31 +00:00
|
|
|
global NS use_ttk
|
2007-07-04 20:38:13 +00:00
|
|
|
if {![winfo exists $w.none_r]} {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::radiobutton $w.none_r \
|
2007-07-04 20:38:13 +00:00
|
|
|
-value none \
|
|
|
|
-variable @revtype
|
2010-01-26 00:05:31 +00:00
|
|
|
if {!$use_ttk} {$w.none_r configure -anchor w}
|
2007-07-04 20:38:13 +00:00
|
|
|
grid $w.none_r -sticky we -padx {0 5} -columnspan 2
|
2007-07-04 03:33:59 +00:00
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
$w.none_r configure -text $text
|
2007-07-04 03:33:59 +00:00
|
|
|
}
|
|
|
|
|
2007-07-04 02:57:18 +00:00
|
|
|
method get {} {
|
|
|
|
switch -- $revtype {
|
2007-07-04 20:38:13 +00:00
|
|
|
head -
|
|
|
|
trck -
|
|
|
|
tag {
|
|
|
|
set i [$w_list curselection]
|
|
|
|
if {$i ne {}} {
|
|
|
|
return [lindex $cur_specs $i 0]
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-08 22:40:56 +00:00
|
|
|
HEAD { return HEAD }
|
2007-07-04 20:38:13 +00:00
|
|
|
expr { return $c_expr }
|
|
|
|
none { return {} }
|
2007-07-04 02:57:18 +00:00
|
|
|
default { error "unknown type of revision" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-05 05:07:06 +00:00
|
|
|
method pick_tracking_branch {} {
|
|
|
|
set revtype trck
|
|
|
|
}
|
|
|
|
|
2007-07-08 22:40:56 +00:00
|
|
|
method focus_filter {} {
|
|
|
|
if {[$w_filter cget -state] eq {normal}} {
|
|
|
|
focus $w_filter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-09 01:34:28 +00:00
|
|
|
method bind_listbox {event script} {
|
|
|
|
bind $w_list $event $script
|
|
|
|
}
|
|
|
|
|
2007-07-08 22:40:56 +00:00
|
|
|
method get_local_branch {} {
|
|
|
|
if {$revtype eq {head}} {
|
|
|
|
return [_expr $this]
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 06:19:53 +00:00
|
|
|
method get_tracking_branch {} {
|
2007-07-04 20:38:13 +00:00
|
|
|
set i [$w_list curselection]
|
|
|
|
if {$i eq {} || $revtype ne {trck}} {
|
2007-07-04 06:19:53 +00:00
|
|
|
return {}
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
return [lrange [lindex $cur_specs $i] 1 end]
|
2007-07-04 06:19:53 +00:00
|
|
|
}
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
method get_commit {} {
|
|
|
|
set e [_expr $this]
|
|
|
|
if {$e eq {}} {
|
|
|
|
return {}
|
2007-07-04 05:10:41 +00:00
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
return [git rev-parse --verify "$e^0"]
|
2007-07-04 05:10:41 +00:00
|
|
|
}
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
method commit_or_die {} {
|
|
|
|
if {[catch {set new [get_commit $this]} err]} {
|
|
|
|
|
|
|
|
# Cleanup the not-so-friendly error from rev-parse.
|
|
|
|
#
|
|
|
|
regsub {^fatal:\s*} $err {} err
|
|
|
|
if {$err eq {Needed a single revision}} {
|
|
|
|
set err {}
|
|
|
|
}
|
|
|
|
|
|
|
|
set top [winfo toplevel $w]
|
2007-09-14 05:50:09 +00:00
|
|
|
set msg [strcat [mc "Invalid revision: %s" [get $this]] "\n\n$err"]
|
2007-07-04 20:38:13 +00:00
|
|
|
tk_messageBox \
|
|
|
|
-icon error \
|
|
|
|
-type ok \
|
|
|
|
-title [wm title $top] \
|
|
|
|
-parent $top \
|
|
|
|
-message $msg
|
|
|
|
error $msg
|
|
|
|
}
|
|
|
|
return $new
|
|
|
|
}
|
|
|
|
|
|
|
|
method _expr {} {
|
|
|
|
switch -- $revtype {
|
|
|
|
head -
|
|
|
|
trck -
|
|
|
|
tag {
|
|
|
|
set i [$w_list curselection]
|
|
|
|
if {$i ne {}} {
|
|
|
|
return [lindex $cur_specs $i 1]
|
|
|
|
} else {
|
2007-07-21 12:21:34 +00:00
|
|
|
error [mc "No revision selected."]
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expr {
|
|
|
|
if {$c_expr ne {}} {
|
|
|
|
return $c_expr
|
|
|
|
} else {
|
2007-07-21 12:21:34 +00:00
|
|
|
error [mc "Revision expression is empty."]
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-08 22:40:56 +00:00
|
|
|
HEAD { return HEAD }
|
2007-07-04 20:38:13 +00:00
|
|
|
none { return {} }
|
|
|
|
default { error "unknown type of revision" }
|
2007-07-04 03:33:59 +00:00
|
|
|
}
|
2007-07-04 02:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
method _validate {d S} {
|
|
|
|
if {$d == 1} {
|
|
|
|
if {[regexp {\s} $S]} {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
if {[string length $S] > 0} {
|
|
|
|
set revtype expr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
method _filter {P} {
|
|
|
|
if {[regexp {\s} $P]} {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
_rebuild $this $P
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
method _select {args} {
|
|
|
|
_rebuild $this $filter
|
2007-07-08 22:40:56 +00:00
|
|
|
focus_filter $this
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
method _rebuild {pat} {
|
|
|
|
set ste normal
|
|
|
|
switch -- $revtype {
|
|
|
|
head { set new $spec_head }
|
|
|
|
trck { set new $spec_trck }
|
|
|
|
tag { set new $spec_tag }
|
|
|
|
expr -
|
2007-07-08 22:40:56 +00:00
|
|
|
HEAD -
|
2007-07-04 20:38:13 +00:00
|
|
|
none {
|
|
|
|
set new [list]
|
|
|
|
set ste disabled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[$w_list cget -state] eq {disabled}} {
|
|
|
|
$w_list configure -state normal
|
|
|
|
}
|
|
|
|
$w_list delete 0 end
|
|
|
|
|
|
|
|
if {$pat ne {}} {
|
|
|
|
set pat *${pat}*
|
|
|
|
}
|
|
|
|
set cur_specs [list]
|
|
|
|
foreach spec $new {
|
|
|
|
set txt [lindex $spec 0]
|
|
|
|
if {$pat eq {} || [string match $pat $txt]} {
|
|
|
|
lappend cur_specs $spec
|
|
|
|
$w_list insert end $txt
|
|
|
|
}
|
|
|
|
}
|
2007-07-09 01:29:54 +00:00
|
|
|
if {$cur_specs ne {}} {
|
|
|
|
$w_list selection clear 0 end
|
|
|
|
$w_list selection set 0
|
|
|
|
}
|
2007-07-04 20:38:13 +00:00
|
|
|
|
|
|
|
if {[$w_filter cget -state] ne $ste} {
|
|
|
|
$w_list configure -state $ste
|
|
|
|
$w_filter configure -state $ste
|
|
|
|
}
|
2007-07-04 02:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
method _delete {current} {
|
|
|
|
if {$current eq $w} {
|
|
|
|
delete_this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 20:38:13 +00:00
|
|
|
method _sb_set {sb orient first last} {
|
2010-01-26 00:05:31 +00:00
|
|
|
global NS
|
2007-07-04 20:38:13 +00:00
|
|
|
set old_focus [focus -lastfor $w]
|
|
|
|
|
|
|
|
if {$first == 0 && $last == 1} {
|
|
|
|
if {[winfo exists $sb]} {
|
|
|
|
destroy $sb
|
|
|
|
if {$old_focus ne {}} {
|
|
|
|
update
|
|
|
|
focus $old_focus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if {![winfo exists $sb]} {
|
|
|
|
if {$orient eq {h}} {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::scrollbar $sb -orient h -command [list $w_list xview]
|
2007-07-04 20:38:13 +00:00
|
|
|
pack $sb -fill x -side bottom -before $w_list
|
|
|
|
} else {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::scrollbar $sb -orient v -command [list $w_list yview]
|
2007-07-04 20:38:13 +00:00
|
|
|
pack $sb -fill y -side right -before $w_list
|
|
|
|
}
|
|
|
|
if {$old_focus ne {}} {
|
|
|
|
update
|
|
|
|
focus $old_focus
|
|
|
|
}
|
|
|
|
}
|
2008-01-22 15:40:13 +00:00
|
|
|
|
|
|
|
catch {$sb set $first $last}
|
2007-07-04 20:38:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-25 08:13:00 +00:00
|
|
|
method _show_tooltip {pos} {
|
|
|
|
if {$tooltip_wm ne {}} {
|
|
|
|
_open_tooltip $this
|
|
|
|
} elseif {$tooltip_timer eq {}} {
|
|
|
|
set tooltip_timer [after 1000 [cb _open_tooltip]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
method _open_tooltip {} {
|
|
|
|
global remote_url
|
|
|
|
|
|
|
|
set tooltip_timer {}
|
|
|
|
set pos_x [winfo pointerx $w_list]
|
|
|
|
set pos_y [winfo pointery $w_list]
|
|
|
|
if {[winfo containing $pos_x $pos_y] ne $w_list} {
|
|
|
|
_hide_tooltip $this
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set pos @[join [list \
|
|
|
|
[expr {$pos_x - [winfo rootx $w_list]}] \
|
|
|
|
[expr {$pos_y - [winfo rooty $w_list]}]] ,]
|
|
|
|
set lno [$w_list index $pos]
|
|
|
|
if {$lno eq {}} {
|
|
|
|
_hide_tooltip $this
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set spec [lindex $cur_specs $lno]
|
|
|
|
set refn [lindex $spec 1]
|
|
|
|
if {$refn eq {}} {
|
|
|
|
_hide_tooltip $this
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$tooltip_wm eq {}} {
|
|
|
|
set tooltip_wm [toplevel $w_list.tooltip -borderwidth 1]
|
2011-10-19 13:26:29 +00:00
|
|
|
catch {wm attributes $tooltip_wm -type tooltip}
|
2007-07-25 08:13:00 +00:00
|
|
|
wm overrideredirect $tooltip_wm 1
|
|
|
|
wm transient $tooltip_wm [winfo toplevel $w_list]
|
|
|
|
set tooltip_t $tooltip_wm.label
|
|
|
|
text $tooltip_t \
|
|
|
|
-takefocus 0 \
|
|
|
|
-highlightthickness 0 \
|
|
|
|
-relief flat \
|
|
|
|
-borderwidth 0 \
|
|
|
|
-wrap none \
|
|
|
|
-background lightyellow \
|
|
|
|
-foreground black
|
|
|
|
$tooltip_t tag conf section_header -font font_uibold
|
|
|
|
bind $tooltip_wm <Escape> [cb _hide_tooltip]
|
|
|
|
pack $tooltip_t
|
|
|
|
} else {
|
|
|
|
$tooltip_t conf -state normal
|
|
|
|
$tooltip_t delete 0.0 end
|
|
|
|
}
|
|
|
|
|
|
|
|
set data $tip_data($refn)
|
|
|
|
if {[lindex $data 0 0] eq {tag}} {
|
|
|
|
set tag [lindex $data 0]
|
|
|
|
if {[lindex $data 1 0] eq {commit}} {
|
|
|
|
set cmit [lindex $data 1]
|
|
|
|
} else {
|
|
|
|
set cmit {}
|
|
|
|
}
|
|
|
|
} elseif {[lindex $data 0 0] eq {commit}} {
|
|
|
|
set tag {}
|
|
|
|
set cmit [lindex $data 0]
|
|
|
|
}
|
|
|
|
|
2007-07-25 08:20:02 +00:00
|
|
|
$tooltip_t insert end [lindex $spec 0]
|
|
|
|
set last [_reflog_last $this [lindex $spec 1]]
|
|
|
|
if {$last ne {}} {
|
|
|
|
$tooltip_t insert end "\n"
|
2007-09-10 04:40:46 +00:00
|
|
|
$tooltip_t insert end [mc "Updated"]
|
2007-07-25 08:20:02 +00:00
|
|
|
$tooltip_t insert end " $last"
|
|
|
|
}
|
|
|
|
$tooltip_t insert end "\n"
|
2007-07-25 08:13:00 +00:00
|
|
|
|
|
|
|
if {$tag ne {}} {
|
|
|
|
$tooltip_t insert end "\n"
|
2007-09-10 04:40:46 +00:00
|
|
|
$tooltip_t insert end [mc "Tag"] section_header
|
2007-07-25 08:13:00 +00:00
|
|
|
$tooltip_t insert end " [lindex $tag 1]\n"
|
|
|
|
$tooltip_t insert end [lindex $tag 2]
|
|
|
|
$tooltip_t insert end " ([lindex $tag 3])\n"
|
|
|
|
$tooltip_t insert end [lindex $tag 4]
|
|
|
|
$tooltip_t insert end "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$cmit ne {}} {
|
|
|
|
$tooltip_t insert end "\n"
|
2007-09-12 20:02:35 +00:00
|
|
|
$tooltip_t insert end [mc "Commit@@noun"] section_header
|
2007-07-25 08:13:00 +00:00
|
|
|
$tooltip_t insert end " [lindex $cmit 1]\n"
|
|
|
|
$tooltip_t insert end [lindex $cmit 2]
|
|
|
|
$tooltip_t insert end " ([lindex $cmit 3])\n"
|
|
|
|
$tooltip_t insert end [lindex $cmit 4]
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[llength $spec] > 2} {
|
|
|
|
$tooltip_t insert end "\n"
|
2007-09-10 04:40:46 +00:00
|
|
|
$tooltip_t insert end [mc "Remote"] section_header
|
2007-07-25 08:13:00 +00:00
|
|
|
$tooltip_t insert end " [lindex $spec 2]\n"
|
2007-09-10 04:40:46 +00:00
|
|
|
$tooltip_t insert end [mc "URL"]
|
2007-07-25 08:13:00 +00:00
|
|
|
$tooltip_t insert end " $remote_url([lindex $spec 2])\n"
|
2007-09-10 04:40:46 +00:00
|
|
|
$tooltip_t insert end [mc "Branch"]
|
2007-07-25 08:13:00 +00:00
|
|
|
$tooltip_t insert end " [lindex $spec 3]"
|
|
|
|
}
|
|
|
|
|
|
|
|
$tooltip_t conf -state disabled
|
|
|
|
_position_tooltip $this
|
|
|
|
}
|
|
|
|
|
2007-07-25 08:20:02 +00:00
|
|
|
method _reflog_last {name} {
|
|
|
|
if {[info exists reflog_last($name)]} {
|
|
|
|
return reflog_last($name)
|
|
|
|
}
|
|
|
|
|
|
|
|
set last {}
|
|
|
|
if {[catch {set last [file mtime [gitdir $name]]}]
|
|
|
|
&& ![catch {set g [open [gitdir logs $name] r]}]} {
|
|
|
|
fconfigure $g -translation binary
|
|
|
|
while {[gets $g line] >= 0} {
|
|
|
|
if {[regexp {> ([1-9][0-9]*) } $line line when]} {
|
|
|
|
set last $when
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close $g
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$last ne {}} {
|
2007-09-10 05:54:16 +00:00
|
|
|
set last [format_date $last]
|
2007-07-25 08:20:02 +00:00
|
|
|
}
|
|
|
|
set reflog_last($name) $last
|
|
|
|
return $last
|
|
|
|
}
|
|
|
|
|
2007-07-25 08:13:00 +00:00
|
|
|
method _position_tooltip {} {
|
|
|
|
set max_h [lindex [split [$tooltip_t index end] .] 0]
|
|
|
|
set max_w 0
|
|
|
|
for {set i 1} {$i <= $max_h} {incr i} {
|
|
|
|
set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1]
|
|
|
|
if {$c > $max_w} {set max_w $c}
|
|
|
|
}
|
|
|
|
$tooltip_t conf -width $max_w -height $max_h
|
|
|
|
|
|
|
|
set req_w [winfo reqwidth $tooltip_t]
|
|
|
|
set req_h [winfo reqheight $tooltip_t]
|
|
|
|
set pos_x [expr {[winfo pointerx .] + 5}]
|
|
|
|
set pos_y [expr {[winfo pointery .] + 10}]
|
|
|
|
|
|
|
|
set g "${req_w}x${req_h}"
|
2011-07-11 12:55:38 +00:00
|
|
|
if {[tk windowingsystem] eq "win32" || $pos_x >= 0} {append g +}
|
2007-07-25 08:13:00 +00:00
|
|
|
append g $pos_x
|
2011-07-11 12:55:38 +00:00
|
|
|
if {[tk windowingsystem] eq "win32" || $pos_y >= 0} {append g +}
|
2007-07-25 08:13:00 +00:00
|
|
|
append g $pos_y
|
|
|
|
|
|
|
|
wm geometry $tooltip_wm $g
|
|
|
|
raise $tooltip_wm
|
|
|
|
}
|
|
|
|
|
|
|
|
method _hide_tooltip {} {
|
|
|
|
if {$tooltip_wm ne {}} {
|
|
|
|
destroy $tooltip_wm
|
|
|
|
set tooltip_wm {}
|
|
|
|
}
|
|
|
|
if {$tooltip_timer ne {}} {
|
|
|
|
after cancel $tooltip_timer
|
|
|
|
set tooltip_timer {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 02:57:18 +00:00
|
|
|
}
|