git-gui: Use progress meter in the status bar during index updates

If we are updating the index to stage or unstage changes or reverting
files in the working directory we can use the progress handling parts
of our status bar to perform this display work, reducing the amount of
code duplication we have in the index handling module.

Unfortunately the status bar is still a strict approximation as it is
unable to know when git-update-index has processed the data we fed to
it.  The progress bar is actually a progress of the pipe buffer filling
up in the OS, not of the actual work done.  Still, it tells the user we
are working and that has some value.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2007-10-07 18:12:31 -07:00
parent 51e1eadb7c
commit 1cad232f92

View File

@ -12,12 +12,7 @@ proc update_indexinfo {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}] set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25} if {$batch > 25} {set batch 25}
ui_status [format \ $::main_status start $msg [mc "files"]
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
set fd [git_write update-index -z --index-info] set fd [git_write update-index -z --index-info]
fconfigure $fd \ fconfigure $fd \
-blocking 0 \ -blocking 0 \
@ -31,18 +26,18 @@ proc update_indexinfo {msg pathList after} {
$pathList \ $pathList \
$totalCnt \ $totalCnt \
$batch \ $batch \
$msg \
$after \ $after \
] ]
} }
proc write_update_indexinfo {fd pathList totalCnt batch msg after} { proc write_update_indexinfo {fd pathList totalCnt batch after} {
global update_index_cp global update_index_cp
global file_states current_diff_path global file_states current_diff_path
if {$update_index_cp >= $totalCnt} { if {$update_index_cp >= $totalCnt} {
close $fd close $fd
unlock_index unlock_index
$::main_status stop
uplevel #0 $after uplevel #0 $after
return return
} }
@ -68,12 +63,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
display_file $path $new display_file $path $new
} }
ui_status [format \ $::main_status update $update_index_cp $totalCnt
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
} }
proc update_index {msg pathList after} { proc update_index {msg pathList after} {
@ -87,12 +77,7 @@ proc update_index {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}] set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25} if {$batch > 25} {set batch 25}
ui_status [format \ $::main_status start $msg [mc "files"]
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
set fd [git_write update-index --add --remove -z --stdin] set fd [git_write update-index --add --remove -z --stdin]
fconfigure $fd \ fconfigure $fd \
-blocking 0 \ -blocking 0 \
@ -106,18 +91,18 @@ proc update_index {msg pathList after} {
$pathList \ $pathList \
$totalCnt \ $totalCnt \
$batch \ $batch \
$msg \
$after \ $after \
] ]
} }
proc write_update_index {fd pathList totalCnt batch msg after} { proc write_update_index {fd pathList totalCnt batch after} {
global update_index_cp global update_index_cp
global file_states current_diff_path global file_states current_diff_path
if {$update_index_cp >= $totalCnt} { if {$update_index_cp >= $totalCnt} {
close $fd close $fd
unlock_index unlock_index
$::main_status stop
uplevel #0 $after uplevel #0 $after
return return
} }
@ -147,12 +132,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
display_file $path $new display_file $path $new
} }
ui_status [format \ $::main_status update $update_index_cp $totalCnt
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
} }
proc checkout_index {msg pathList after} { proc checkout_index {msg pathList after} {
@ -166,12 +146,7 @@ proc checkout_index {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}] set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25} if {$batch > 25} {set batch 25}
ui_status [format \ $::main_status start $msg [mc "files"]
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
set fd [git_write checkout-index \ set fd [git_write checkout-index \
--index \ --index \
--quiet \ --quiet \
@ -191,18 +166,18 @@ proc checkout_index {msg pathList after} {
$pathList \ $pathList \
$totalCnt \ $totalCnt \
$batch \ $batch \
$msg \
$after \ $after \
] ]
} }
proc write_checkout_index {fd pathList totalCnt batch msg after} { proc write_checkout_index {fd pathList totalCnt batch after} {
global update_index_cp global update_index_cp
global file_states current_diff_path global file_states current_diff_path
if {$update_index_cp >= $totalCnt} { if {$update_index_cp >= $totalCnt} {
close $fd close $fd
unlock_index unlock_index
$::main_status stop
uplevel #0 $after uplevel #0 $after
return return
} }
@ -222,12 +197,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
} }
} }
ui_status [format \ $::main_status update $update_index_cp $totalCnt
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
} }
proc unstage_helper {txt paths} { proc unstage_helper {txt paths} {