@matheusbsbs / matheus-bagliano / commits / 982cf98fa4
Fork 0

git-gui: Display a progress bar during blame annotation gathering

Computing the blame records for a large file with a long project history can take git a while to run; traditionally we have shown a little meter in the status area of our blame viewer that lets the user know how many lines have been finished, and how far we are through the process. Usually such progress indicators are drawn with a little progress bar in the window, where the bar shows how much has been completed and hides itself when the process is complete. I'm using a very simple hack to do that: draw a canvas with a filled rectangle. Of course the time remaining has absolutely no relationship to the progress meter. It could take very little time for git-blame to get the first 90% of the file, and then it could take many times that to get the remaining 10%. So the progress meter doesn't really have any sort of assurances that it relates to the true progress of the work. But in practice on some ugly history it does seem to hold a reasonable indicator to the completion status. Besides, its amusing to watch and that keeps the user from realizing git is being somewhat slow. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jun 1, 2007 at 18:29 UTC 982cf98fa47b8db890b84febda325e461f8a407d
1 file changed +20 -8
lib/blame.tcl
+20 -8
@@ -136,13 +136,6 @@ constructor new {i_commit i_path} {
136 grid columnconfigure $w.file_pane.out 3 -weight 1
137 grid rowconfigure $w.file_pane.out 0 -weight 1
138
139 - label $w.status \
140 - -textvariable @status \
141 - -anchor w \
142 - -justify left \
143 - -borderwidth 1 \
144 - -relief sunken
145 -
139 set w_cmit $w.file_pane.cm.t
140 text $w_cmit \
141 -background white -borderwidth 0 \
@@ -171,6 +164,23 @@ constructor new {i_commit i_path} {
164 pack $w.file_pane.cm.sbx -side bottom -fill x
165 pack $w_cmit -expand 1 -fill both
166
167 + frame $w.status \
168 + -borderwidth 1 \
169 + -relief sunken
170 + label $w.status.l \
171 + -textvariable @status \
172 + -anchor w \
173 + -justify left
174 + canvas $w.status.c \
175 + -width 100 \
176 + -height [expr {int([winfo reqheight $w.status.l] * 0.6)}] \
177 + -borderwidth 1 \
178 + -relief groove \
179 + -highlightt 0
180 + $w.status.c create rectangle 0 0 0 20 -tags bar -fill navy
181 + pack $w.status.l -side left
182 + pack $w.status.c -side right
183 +
184 menu $w.ctxm -tearoff 0
185 $w.ctxm add command \
186 -label "Copy Commit" \
@@ -226,7 +236,7 @@ constructor new {i_commit i_path} {
236
237 bind $w_cmit <Button-1> [list focus $w_cmit]
238 bind $top <Visibility> [list focus $top]
229 - bind $top <Destroy> [list delete_this $this]
239 + bind $w_file <Destroy> [list delete_this $this]
240
241 grid configure $w.path -sticky ew
242 grid configure $w.file_pane -sticky nsew
@@ -438,6 +448,7 @@ method _read_blame {fd} {
448 if {[eof $fd]} {
449 close $fd
450 set status {Annotation complete.}
451 + destroy $w.status.c
452 } else {
453 _status $this
454 }
@@ -452,6 +463,7 @@ method _status {} {
463 set status [format \
464 "Loading annotations... %i of %i lines annotated (%2i%%)" \
465 $have $total $pdone]
466 + $w.status.c coords bar 0 0 $pdone 20
467 }
468
469 method _click {cur_w pos} {