gitk: Add a progress bar to show progress while resetting
Since git reset now gets chatty while resetting, we were getting errors reported when a reset was done using the "reset branch to here" menu item. With this we now read the progress messages from git reset and update a progress bar. Because git reset outputs the progress messages to standard error, and Tcl treats messages to standard error as error messages, we have to invoke git reset via a shell and redirect standard error into standard output. This also fixes a bug in computing descendent heads when head ids are changed via a reset. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Jun 26, 2007 at 11:09 UTC
706d6c3e76fc5f7f988b056015689b489eb8f6b5
1 file changed
+45
-7
gitk
+45
-7
@@ -5851,19 +5851,54 @@ proc resethead {} {
5851
bind $w <Visibility> "grab $w; focus $w"
5852
tkwait window $w
5853
if {!$confirm_ok} return
5854
- dohidelocalchanges
5855
- if {[catch {exec git reset --$resettype $rowmenuid} err]} {
5854
+ if {[catch {set fd [open \
5855
+ [list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
5856
error_popup $err
5857
} else {
5858
- set oldhead $mainheadid
5859
- movedhead $rowmenuid $mainhead
5860
- set mainheadid $rowmenuid
5858
+ dohidelocalchanges
5859
+ set w ".resetprogress"
5860
+ filerun $fd [list readresetstat $fd $w]
5861
+ toplevel $w
5862
+ wm transient $w
5863
+ wm title $w "Reset progress"
5864
+ message $w.m -text "Reset in progress, please wait..." \
5865
+ -justify center -aspect 1000
5866
+ pack $w.m -side top -fill x -padx 20 -pady 5
5867
+ canvas $w.c -width 150 -height 20 -bg white
5868
+ $w.c create rect 0 0 0 20 -fill green -tags rect
5869
+ pack $w.c -side top -fill x -padx 20 -pady 5 -expand 1
5870
+ nowbusy reset
5871
+ }
5872
+}
5873
+
5874
+proc readresetstat {fd w} {
5875
+ global mainhead mainheadid showlocalchanges
5876
+
5877
+ if {[gets $fd line] >= 0} {
5878
+ if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
5879
+ set x [expr {($m * 150) / $n}]
5880
+ $w.c coords rect 0 0 $x 20
5881
+ }
5882
+ return 1
5883
+ }
5884
+ destroy $w
5885
+ notbusy reset
5886
+ if {[catch {close $fd} err]} {
5887
+ error_popup $err
5888
+ }
5889
+ set oldhead $mainheadid
5890
+ set newhead [exec git rev-parse HEAD]
5891
+ if {$newhead ne $oldhead} {
5892
+ movehead $newhead $mainhead
5893
+ movedhead $newhead $mainhead
5894
+ set mainheadid $newhead
5895
redrawtags $oldhead
5862
- redrawtags $rowmenuid
5896
+ redrawtags $newhead
5897
}
5898
if {$showlocalchanges} {
5899
doshowlocalchanges
5900
}
5901
+ return 0
5902
}
5903
5904
# context menu for a head
@@ -6742,7 +6777,10 @@ proc descheads {id} {
6777
}
6778
foreach a $arcnos($id) {
6779
if {$archeads($a) ne {}} {
6745
- set ret [concat $ret $archeads($a)]
6780
+ validate_archeads $a
6781
+ if {$archeads($a) ne {}} {
6782
+ set ret [concat $ret $archeads($a)]
6783
+ }
6784
}
6785
set d $arcstart($a)
6786
if {![info exists seen($d)]} {