Commits

Anonymous committed c17c175

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>

Comments (0)

Files changed (1)

 
 image create photo ::blame::img_back_arrow -data {R0lGODlhGAAYAIUAAPwCBEzKXFTSZIz+nGzmhGzqfGTidIT+nEzGXHTqhGzmfGzifFzadETCVES+VARWDFzWbHzyjAReDGTadFTOZDSyRDyyTCymPARaFGTedFzSbDy2TCyqRCyqPARaDAyCHES6VDy6VCyiPAR6HCSeNByWLARyFARiDARqFGTifARiFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAYABgAAAajQIBwSCwaj8ikcsk0BppJwRPqHEypQwHBis0WDAdEFyBIKBaMAKLBdjQeSkFBYTBAIvgEoS6JmhUTEwIUDQ4VFhcMGEhyCgoZExoUaxsWHB0THkgfAXUGAhoBDSAVFR0XBnCbDRmgog0hpSIiDJpJIyEQhBUcJCIlwA22SSYVogknEg8eD82qSigdDSknY0IqJQXPYxIl1dZCGNvWw+Dm510GQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7}
 
-field commit    ; # input commit to blame
-field path      ; # input filename to view in $commit
+# Persistant data (survives loads)
+#
 field history {}; # viewer history: {commit path}
+field header    ; # array commit,key -> header field
 
+# Tk UI control paths
+#
 field w          ; # top window in this viewer
 field w_back     ; # our back button
 field w_path     ; # label showing the current file path
 field status     ; # text variable bound to status bar
 field old_height ; # last known height of $w.file_pane
 
-field current_fd       {} ; # background process running
-field highlight_line   -1 ; # current line selected
-field highlight_commit {} ; # sha1 of commit selected
+# Tk UI colors
+#
+field active_color #c0edc5
+field group_colors {
+	#d6d6d6
+	#e1e1e1
+	#ececec
+}
+
+# Current blame data; cleared/reset on each load
+#
+field commit               ; # input commit to blame
+field path                 ; # input filename to view in $commit
+
+field current_fd        {} ; # background process running
+field highlight_line    -1 ; # current line selected
+field highlight_commit  {} ; # sha1 of commit selected
 
 field total_lines       0  ; # total length of file
 field blame_lines       0  ; # number of lines computed
-field commit_count      0  ; # number of commits loaded
-field order                ; # array commit -> receipt order
-field header               ; # array commit,key -> header field
+field have_commit          ; # array commit -> 1
 field line_commit          ; # array line -> sha1 commit
 field line_file            ; # array line -> file name
 
-field r_commit      ; # commit currently being parsed
-field r_orig_line   ; # original line number
-field r_final_line  ; # final line number
-field r_line_count  ; # lines in this region
+field r_commit             ; # commit currently being parsed
+field r_orig_line          ; # original line number
+field r_final_line         ; # final line number
+field r_line_count         ; # lines in this region
 
-field tooltip_wm     {} ; # Current tooltip toplevel, if open
-field tooltip_timer  {} ; # Current timer event for our tooltip
-field tooltip_commit {} ; # Commit in tooltip
-field tooltip_text   {} ; # Text in current tooltip
-
-variable active_color #c0edc5
-variable group_colors {
-	#d6d6d6
-	#e1e1e1
-	#ececec
-}
+field tooltip_wm        {} ; # Current tooltip toplevel, if open
+field tooltip_timer     {} ; # Current timer event for our tooltip
+field tooltip_commit    {} ; # Commit in tooltip
+field tooltip_text      {} ; # Text in current tooltip
 
 constructor new {i_commit i_path} {
-	variable active_color
 	global cursor_ptr
 
 	set commit $i_commit
 		set highlight_commit {}
 		set total_lines 0
 		set blame_lines 0
-		set commit_count 0
-		array unset order
+		array unset have_commit
 		array unset line_commit
 		array unset line_file
 
 } ifdeleted { catch {close $fd} }
 
 method _read_blame {fd} {
-	variable group_colors
-
 	if {$fd ne $current_fd} {
 		catch {close $fd}
 		return
 			set r_final_line $final_line
 			set r_line_count $line_count
 
-			if {[catch {set g $order($cmit)}]} {
+			if {[catch {set g $have_commit($cmit)}]} {
 				set bg [lindex $group_colors 0]
 				set group_colors [lrange $group_colors 1 end]
 				lappend group_colors $bg
 				$w_line tag conf g$cmit -background $bg
 				$w_file tag conf g$cmit -background $bg
 
-				set order($cmit) $commit_count
-				incr commit_count
+				set have_commit($cmit) 1
 			}
 		} elseif {[string match {filename *} $line]} {
 			set file [string range $line 9 end]
 
 method _showcommit {lno} {
 	global repo_config
-	variable active_color
 
 	if {$highlight_commit ne {}} {
 		set cmit $highlight_commit
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.