git-gui: Better document our blame variables
The array variable "order" used to be used to tell us in what order each commit was received in. Recent changes have removed that need for an ordering and the "order" array is now just a boolean 'do we have that commit yet' flag. The colors were moved to fields, so they appear inside of the blame viewer instance. This keeps two different concurrently running blame viewers from stepping on each other's ordering of the colors in group_colors. Most of the other fields were moved around a little bit so that they are organized by major category and value lifespan. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jun 2, 2007 at 15:13 UTC
c17c1751339bbb13e8927b0e98274cfee406821e
1 file changed
+34
-32
lib/blame.tcl
+34
-32
@@ -5,10 +5,13 @@ class blame {
5
6
image create photo ::blame::img_back_arrow -data {R0lGODlhGAAYAIUAAPwCBEzKXFTSZIz+nGzmhGzqfGTidIT+nEzGXHTqhGzmfGzifFzadETCVES+VARWDFzWbHzyjAReDGTadFTOZDSyRDyyTCymPARaFGTedFzSbDy2TCyqRCyqPARaDAyCHES6VDy6VCyiPAR6HCSeNByWLARyFARiDARqFGTifARiFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAYABgAAAajQIBwSCwaj8ikcsk0BppJwRPqHEypQwHBis0WDAdEFyBIKBaMAKLBdjQeSkFBYTBAIvgEoS6JmhUTEwIUDQ4VFhcMGEhyCgoZExoUaxsWHB0THkgfAXUGAhoBDSAVFR0XBnCbDRmgog0hpSIiDJpJIyEQhBUcJCIlwA22SSYVogknEg8eD82qSigdDSknY0IqJQXPYxIl1dZCGNvWw+Dm510GQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7}
7
8
-field commit ; # input commit to blame
9
-field path ; # input filename to view in $commit
8
+# Persistant data (survives loads)
9
+#
10
field history {}; # viewer history: {commit path}
11
+field header ; # array commit,key -> header field
12
13
+# Tk UI control paths
14
+#
15
field w ; # top window in this viewer
16
field w_back ; # our back button
17
field w_path ; # label showing the current file path
@@ -19,37 +22,41 @@ field w_cmit ; # pane showing commit message
22
field status ; # text variable bound to status bar
23
field old_height ; # last known height of $w.file_pane
24
22
-field current_fd {} ; # background process running
23
-field highlight_line -1 ; # current line selected
24
-field highlight_commit {} ; # sha1 of commit selected
25
+# Tk UI colors
26
+#
27
+field active_color #c0edc5
28
+field group_colors {
29
+ #d6d6d6
30
+ #e1e1e1
31
+ #ececec
32
+}
33
+
34
+# Current blame data; cleared/reset on each load
35
+#
36
+field commit ; # input commit to blame
37
+field path ; # input filename to view in $commit
38
+
39
+field current_fd {} ; # background process running
40
+field highlight_line -1 ; # current line selected
41
+field highlight_commit {} ; # sha1 of commit selected
42
43
field total_lines 0 ; # total length of file
44
field blame_lines 0 ; # number of lines computed
28
-field commit_count 0 ; # number of commits loaded
29
-field order ; # array commit -> receipt order
30
-field header ; # array commit,key -> header field
45
+field have_commit ; # array commit -> 1
46
field line_commit ; # array line -> sha1 commit
47
field line_file ; # array line -> file name
48
34
-field r_commit ; # commit currently being parsed
35
-field r_orig_line ; # original line number
36
-field r_final_line ; # final line number
37
-field r_line_count ; # lines in this region
49
+field r_commit ; # commit currently being parsed
50
+field r_orig_line ; # original line number
51
+field r_final_line ; # final line number
52
+field r_line_count ; # lines in this region
53
39
-field tooltip_wm {} ; # Current tooltip toplevel, if open
40
-field tooltip_timer {} ; # Current timer event for our tooltip
41
-field tooltip_commit {} ; # Commit in tooltip
42
-field tooltip_text {} ; # Text in current tooltip
43
-
44
-variable active_color #c0edc5
45
-variable group_colors {
46
- #d6d6d6
47
- #e1e1e1
48
- #ececec
49
-}
54
+field tooltip_wm {} ; # Current tooltip toplevel, if open
55
+field tooltip_timer {} ; # Current timer event for our tooltip
56
+field tooltip_commit {} ; # Commit in tooltip
57
+field tooltip_text {} ; # Text in current tooltip
58
59
constructor new {i_commit i_path} {
52
- variable active_color
60
global cursor_ptr
61
62
set commit $i_commit
@@ -307,8 +314,7 @@ method _load {} {
314
set highlight_commit {}
315
set total_lines 0
316
set blame_lines 0
310
- set commit_count 0
311
- array unset order
317
+ array unset have_commit
318
array unset line_commit
319
array unset line_file
320
@@ -449,8 +455,6 @@ method _read_file {fd} {
455
} ifdeleted { catch {close $fd} }
456
457
method _read_blame {fd} {
452
- variable group_colors
453
-
458
if {$fd ne $current_fd} {
459
catch {close $fd}
460
return
@@ -465,7 +469,7 @@ method _read_blame {fd} {
469
set r_final_line $final_line
470
set r_line_count $line_count
471
468
- if {[catch {set g $order($cmit)}]} {
472
+ if {[catch {set g $have_commit($cmit)}]} {
473
set bg [lindex $group_colors 0]
474
set group_colors [lrange $group_colors 1 end]
475
lappend group_colors $bg
@@ -474,8 +478,7 @@ method _read_blame {fd} {
478
$w_line tag conf g$cmit -background $bg
479
$w_file tag conf g$cmit -background $bg
480
477
- set order($cmit) $commit_count
478
- incr commit_count
481
+ set have_commit($cmit) 1
482
}
483
} elseif {[string match {filename *} $line]} {
484
set file [string range $line 9 end]
@@ -635,7 +638,6 @@ method _load_commit {pos} {
638
639
method _showcommit {lno} {
640
global repo_config
638
- variable active_color
641
642
if {$highlight_commit ne {}} {
643
set cmit $highlight_commit