git-gui: Display both commits in our tooltips
If we have commit data from both the simple blame and the rename/move tracking blame and they differ than there is a bigger story to tell. We now include data from both commits so that the user can see that this link as moved, who moved it, and where it originated from. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jun 2, 2007 at 19:03 UTC
383d4e0f8b72f739c16ef7d723a134d59a0a0c2f
1 file changed
+72
-58
lib/blame.tcl
+72
-58
@@ -56,9 +56,9 @@ field r_final_line ; # final line number
56
field r_line_count ; # lines in this region
57
58
field tooltip_wm {} ; # Current tooltip toplevel, if open
59
+field tooltip_t {} ; # Text widget in $tooltip_wm
60
field tooltip_timer {} ; # Current timer event for our tooltip
60
-field tooltip_commit {} ; # Commit in tooltip
61
-field tooltip_text {} ; # Text in current tooltip
61
+field tooltip_commit {} ; # Commit(s) in tooltip
62
63
constructor new {i_commit i_path} {
64
global cursor_ptr
@@ -653,6 +653,7 @@ method _showcommit {cur_w lno} {
653
if {$highlight_commit ne {}} {
654
foreach i $w_columns {
655
$i tag conf g$highlight_commit -background $old_bgcolor
656
+ $i tag lower g$highlight_commit
657
}
658
}
659
@@ -677,6 +678,7 @@ method _showcommit {cur_w lno} {
678
set old_bgcolor [$w_file tag cget g$cmit -background]
679
foreach i $w_columns {
680
$i tag conf g$cmit -background $active_color
681
+ $i tag raise g$cmit
682
}
683
684
set author_name {}
@@ -746,7 +748,7 @@ method _showcommit {cur_w lno} {
748
set highlight_line $lno
749
set highlight_commit $cmit
750
749
- if {$highlight_commit eq $tooltip_commit} {
751
+ if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
752
_hide_tooltip $this
753
}
754
}
@@ -765,26 +767,7 @@ method _copycommit {} {
767
}
768
769
method _show_tooltip {cur_w pos} {
768
- set lno [lindex [split [$cur_w index $pos] .] 0]
769
- if {$cur_w eq $w_amov} {
770
- set dat [lindex $amov_data $lno]
771
- } else {
772
- set dat [lindex $asim_data $lno]
773
- }
774
- if {$dat eq {}} {
775
- _hide_tooltip $this
776
- return
777
- }
778
- set cmit [lindex $dat 0]
779
-
780
- if {$cmit eq $highlight_commit} {
781
- _hide_tooltip $this
782
- return
783
- }
784
-
785
- if {$cmit eq $tooltip_commit} {
786
- _position_tooltip $this
787
- } elseif {$tooltip_wm ne {}} {
770
+ if {$tooltip_wm ne {}} {
771
_open_tooltip $this $cur_w
772
} elseif {$tooltip_timer eq {}} {
773
set tooltip_timer [after 1000 [cb _open_tooltip $cur_w]]
@@ -800,70 +783,101 @@ method _open_tooltip {cur_w} {
783
return
784
}
785
786
+ if {$tooltip_wm ne "$cur_w.tooltip"} {
787
+ _hide_tooltip $this
788
+
789
+ set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
790
+ wm overrideredirect $tooltip_wm 1
791
+ wm transient $tooltip_wm [winfo toplevel $cur_w]
792
+ set tooltip_t $tooltip_wm.label
793
+ text $tooltip_t \
794
+ -takefocus 0 \
795
+ -highlightthickness 0 \
796
+ -relief flat \
797
+ -borderwidth 0 \
798
+ -wrap none \
799
+ -background lightyellow \
800
+ -foreground black
801
+ $tooltip_t tag conf section_header -font font_uibold
802
+ pack $tooltip_t
803
+ } else {
804
+ $tooltip_t conf -state normal
805
+ $tooltip_t delete 0.0 end
806
+ }
807
+
808
set pos @[join [list \
809
[expr {$pos_x - [winfo rootx $cur_w]}] \
810
[expr {$pos_y - [winfo rooty $cur_w]}]] ,]
811
set lno [lindex [split [$cur_w index $pos] .] 0]
812
if {$cur_w eq $w_amov} {
813
set dat [lindex $amov_data $lno]
814
+ set org {}
815
} else {
816
set dat [lindex $asim_data $lno]
817
+ set org [lindex $amov_data $lno]
818
}
819
+
820
set cmit [lindex $dat 0]
813
- set file [lindex $dat 1]
821
+ set tooltip_commit [list $cmit]
822
823
set author_name {}
816
- set author_email {}
824
+ set summary {}
825
set author_time {}
826
catch {set author_name $header($cmit,author)}
819
- catch {set author_email $header($cmit,author-mail)}
827
+ catch {set summary $header($cmit,summary)}
828
catch {set author_time [clock format \
829
$header($cmit,author-time) \
830
-format {%Y-%m-%d %H:%M:%S}
831
]}
832
825
- set committer_name {}
826
- set committer_email {}
827
- set committer_time {}
828
- catch {set committer_name $header($cmit,committer)}
829
- catch {set committer_email $header($cmit,committer-mail)}
830
- catch {set committer_time [clock format \
831
- $header($cmit,committer-time) \
832
- -format {%Y-%m-%d %H:%M:%S}
833
- ]}
833
+ $tooltip_t insert end "commit $cmit\n"
834
+ $tooltip_t insert end "$author_name $author_time\n"
835
+ $tooltip_t insert end "$summary"
836
835
- set summary {}
836
- catch {set summary $header($cmit,summary)}
837
+ if {$org ne {} && [lindex $org 0] ne $cmit} {
838
+ $tooltip_t insert 0.0 "Moved Here By:\n" section_header
839
+ set cmit [lindex $org 0]
840
+ set file [lindex $org 1]
841
+ lappend tooltip_commit $cmit
842
838
- set tooltip_commit $cmit
839
- set tooltip_text "commit $cmit
840
-$author_name $author_email $author_time
841
-$summary"
843
+ set author_name {}
844
+ set summary {}
845
+ set author_time {}
846
+ catch {set author_name $header($cmit,author)}
847
+ catch {set summary $header($cmit,summary)}
848
+ catch {set author_time [clock format \
849
+ $header($cmit,author-time) \
850
+ -format {%Y-%m-%d %H:%M:%S}
851
+ ]}
852
843
- if {$file ne $path} {
844
- append tooltip_text "
853
+ $tooltip_t insert end "\n\n"
854
+ $tooltip_t insert end "Originally By:\n" section_header
855
+ $tooltip_t insert end "commit $cmit\n"
856
+ $tooltip_t insert end "$author_name $author_time\n"
857
+ $tooltip_t insert end "$summary"
858
846
-Original File: $file"
859
+ if {$file ne $path} {
860
+ $tooltip_t insert end "\n"
861
+ $tooltip_t insert end "File: " section_header
862
+ $tooltip_t insert end $file
863
+ }
864
}
865
849
- if {$tooltip_wm ne "$cur_w.tooltip"} {
850
- _hide_tooltip $this
851
-
852
- set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
853
- wm overrideredirect $tooltip_wm 1
854
- wm transient $tooltip_wm [winfo toplevel $cur_w]
855
- pack [label $tooltip_wm.label \
856
- -background lightyellow \
857
- -foreground black \
858
- -textvariable @tooltip_text \
859
- -justify left]
860
- }
866
+ $tooltip_t conf -state disabled
867
_position_tooltip $this
868
}
869
870
method _position_tooltip {} {
865
- set req_w [winfo reqwidth $tooltip_wm.label]
866
- set req_h [winfo reqheight $tooltip_wm.label]
871
+ set max_h [lindex [split [$tooltip_t index end] .] 0]
872
+ set max_w 0
873
+ for {set i 1} {$i <= $max_h} {incr i} {
874
+ set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1]
875
+ if {$c > $max_w} {set max_w $c}
876
+ }
877
+ $tooltip_t conf -width $max_w -height $max_h
878
+
879
+ set req_w [winfo reqwidth $tooltip_t]
880
+ set req_h [winfo reqheight $tooltip_t]
881
set pos_x [expr {[winfo pointerx .] + 5}]
882
set pos_y [expr {[winfo pointery .] + 10}]
883