From 982cf98fa47b8db890b84febda325e461f8a407d Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 1 Jun 2007 18:29:20 -0400 Subject: [PATCH] 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 --- lib/blame.tcl | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/blame.tcl b/lib/blame.tcl index f15e5a072..1223c567a 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -136,13 +136,6 @@ constructor new {i_commit i_path} { grid columnconfigure $w.file_pane.out 3 -weight 1 grid rowconfigure $w.file_pane.out 0 -weight 1 - label $w.status \ - -textvariable @status \ - -anchor w \ - -justify left \ - -borderwidth 1 \ - -relief sunken - set w_cmit $w.file_pane.cm.t text $w_cmit \ -background white -borderwidth 0 \ @@ -171,6 +164,23 @@ constructor new {i_commit i_path} { pack $w.file_pane.cm.sbx -side bottom -fill x pack $w_cmit -expand 1 -fill both + frame $w.status \ + -borderwidth 1 \ + -relief sunken + label $w.status.l \ + -textvariable @status \ + -anchor w \ + -justify left + canvas $w.status.c \ + -width 100 \ + -height [expr {int([winfo reqheight $w.status.l] * 0.6)}] \ + -borderwidth 1 \ + -relief groove \ + -highlightt 0 + $w.status.c create rectangle 0 0 0 20 -tags bar -fill navy + pack $w.status.l -side left + pack $w.status.c -side right + menu $w.ctxm -tearoff 0 $w.ctxm add command \ -label "Copy Commit" \ @@ -226,7 +236,7 @@ constructor new {i_commit i_path} { bind $w_cmit [list focus $w_cmit] bind $top [list focus $top] - bind $top [list delete_this $this] + bind $w_file [list delete_this $this] grid configure $w.path -sticky ew grid configure $w.file_pane -sticky nsew @@ -438,6 +448,7 @@ method _read_blame {fd} { if {[eof $fd]} { close $fd set status {Annotation complete.} + destroy $w.status.c } else { _status $this } @@ -452,6 +463,7 @@ method _status {} { set status [format \ "Loading annotations... %i of %i lines annotated (%2i%%)" \ $have $total $pdone] + $w.status.c coords bar 0 0 $pdone 20 } method _click {cur_w pos} { -- 2.30.2