]> asedeno.scripts.mit.edu Git - git.git/blobdiff - lib/blame.tcl
Merge branch 'maint'
[git.git] / lib / blame.tcl
index 5ea7bfea90d38bb2efe12f0e6fafa56c22c82ce5..76b5168fb32bd93f7824c2b8fb9ceb8ac7e139e4 100644 (file)
@@ -33,6 +33,13 @@ variable group_colors {
        #ececec
 }
 
+# Switches for original location detection
+#
+variable original_options [list -C -C]
+if {[git-version >= 1.5.3]} {
+       lappend original_options -w ; # ignore indentation changes
+}
+
 # Current blame data; cleared/reset on each load
 #
 field commit               ; # input commit to blame
@@ -69,10 +76,10 @@ constructor new {i_commit i_path} {
        make_toplevel top w
        wm title $top "[appname] ([reponame]): File Viewer"
 
-       frame $w.header -background orange
+       frame $w.header -background gold
        label $w.header.commit_l \
                -text {Commit:} \
-               -background orange \
+               -background gold \
                -anchor w \
                -justify left
        set w_back $w.header.commit_b
@@ -81,8 +88,8 @@ constructor new {i_commit i_path} {
                -borderwidth 0 \
                -relief flat \
                -state disabled \
-               -background orange \
-               -activebackground orange
+               -background gold \
+               -activebackground gold
        bind $w_back <Button-1> "
                if {\[$w_back cget -state\] eq {normal}} {
                        [cb _history_menu]
@@ -90,17 +97,17 @@ constructor new {i_commit i_path} {
                "
        label $w.header.commit \
                -textvariable @commit \
-               -background orange \
+               -background gold \
                -anchor w \
                -justify left
        label $w.header.path_l \
                -text {File:} \
-               -background orange \
+               -background gold \
                -anchor w \
                -justify left
        set w_path $w.header.path
        label $w_path \
-               -background orange \
+               -background gold \
                -anchor w \
                -justify left
        pack $w.header.commit_l -side left
@@ -272,6 +279,8 @@ constructor new {i_commit i_path} {
                        set cursorW %W
                        tk_popup $w.ctxm %X %Y
                "
+               bind $i <Shift-Tab> "[list focus $w_cviewer];break"
+               bind $i <Tab>       "[list focus $w_cviewer];break"
        }
 
        foreach i [concat $w_columns $w_cviewer] {
@@ -287,9 +296,10 @@ constructor new {i_commit i_path} {
                bind $i <Control-Key-f> {catch {%W yview scroll  1 pages};break}
        }
 
+       bind $w_cviewer <Shift-Tab> "[list focus $w_file];break"
+       bind $w_cviewer <Tab>       "[list focus $w_file];break"
        bind $w_cviewer <Button-1> [list focus $w_cviewer]
-       bind $top <Visibility> [list focus $top]
-       bind $w_file <Destroy> [list delete_this $this]
+       bind $w_file    <Visibility> [list focus $w_file]
 
        grid configure $w.header -sticky ew
        grid configure $w.file_pane -sticky nsew
@@ -301,8 +311,9 @@ constructor new {i_commit i_path} {
 
        set req_w [winfo reqwidth  $top]
        set req_h [winfo reqheight $top]
+       set scr_h [expr {[winfo screenheight $top] - 100}]
        if {$req_w < 600} {set req_w 600}
-       if {$req_h < 400} {set req_h 400}
+       if {$req_h < $scr_h} {set req_h $scr_h}
        set g "${req_w}x${req_h}"
        wm geometry $top $g
        update
@@ -477,12 +488,18 @@ method _read_file {fd jump} {
                        $w_file yview moveto [lindex $jump 3]
                }
 
-               _exec_blame $this $w_asim @asim_data [list] {}
+               _exec_blame $this $w_asim @asim_data \
+                       [list] \
+                       { copy/move tracking}
        }
 } ifdeleted { catch {close $fd} }
 
 method _exec_blame {cur_w cur_d options cur_s} {
-       set cmd [list nice git blame]
+       set cmd [list]
+       if {![is_Windows] || [is_Cygwin]} {
+               lappend cmd nice
+       }
+       lappend cmd git blame
        set cmd [concat $cmd $options]
        lappend cmd --incremental
        if {$commit eq {}} {
@@ -502,6 +519,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
 method _read_blame {fd cur_w cur_d cur_s} {
        upvar #0 $cur_d line_data
        variable group_colors
+       variable original_options
 
        if {$fd ne $current_fd} {
                catch {close $fd}
@@ -538,6 +556,10 @@ method _read_blame {fd cur_w cur_d cur_s} {
                        set a_name {}
                        catch {set a_name $header($cmit,author)}
                        while {$a_name ne {}} {
+                               if {$author_abbr ne {}
+                                       && [string index $a_name 0] eq {'}} {
+                                       regsub {^'[^']+'\s+} $a_name {} a_name
+                               }
                                if {![regexp {^([[:upper:]])} $a_name _a]} break
                                append author_abbr $_a
                                unset _a
@@ -671,8 +693,8 @@ method _read_blame {fd cur_w cur_d cur_s} {
                close $fd
                if {$cur_w eq $w_asim} {
                        _exec_blame $this $w_amov @amov_data \
-                               [list -M -C -C] \
-                               { move/copy tracking}
+                               $original_options \
+                               { original location}
                } else {
                        set current_fd {}
                        set status {Annotation complete.}
@@ -729,12 +751,12 @@ method _showcommit {cur_w lno} {
                }
        }
 
-       if {$cur_w eq $w_amov} {
-               set dat [lindex $amov_data $lno]
-               set highlight_column $w_amov
-       } else {
+       if {$cur_w eq $w_asim} {
                set dat [lindex $asim_data $lno]
                set highlight_column $w_asim
+       } else {
+               set dat [lindex $amov_data $lno]
+               set highlight_column $w_amov
        }
 
        $w_cviewer conf -state normal
@@ -906,7 +928,9 @@ method _open_tooltip {cur_w} {
        $tooltip_t insert end "$summary"
 
        if {$org ne {} && [lindex $org 0] ne $cmit} {
-               $tooltip_t insert 0.0 "Moved Here By:\n" section_header
+               set save [$tooltip_t get 0.0 end]
+               $tooltip_t delete 0.0 end
+
                set cmit [lindex $org 0]
                set file [lindex $org 1]
                lappend tooltip_commit $cmit
@@ -921,17 +945,19 @@ method _open_tooltip {cur_w} {
                        -format {%Y-%m-%d %H:%M:%S}
                ]}
 
-               $tooltip_t insert end "\n\n"
                $tooltip_t insert end "Originally By:\n" section_header
                $tooltip_t insert end "commit $cmit\n"
                $tooltip_t insert end "$author_name  $author_time\n"
-               $tooltip_t insert end "$summary"
+               $tooltip_t insert end "$summary\n"
 
                if {$file ne $path} {
-                       $tooltip_t insert end "\n"
-                       $tooltip_t insert end "File: " section_header
-                       $tooltip_t insert end $file
+                       $tooltip_t insert end "In File: " section_header
+                       $tooltip_t insert end "$file\n"
                }
+
+               $tooltip_t insert end "\n"
+               $tooltip_t insert end "Copied Or Moved Here By:\n" section_header
+               $tooltip_t insert end $save
        }
 
        $tooltip_t conf -state disabled