@matheusbsbs / matheus-bagliano / commits / 08ba820fd7
Fork 0

gitk: Add a progress bar for checking out a head

Now that git checkout reports progress when checking out files, we can use that to provide a progress bar in gitk. We re-use the green progress bar (formerly used when reading stuff in) for that. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed May 12, 2008 at 10:18 UTC 08ba820fd7d82cd798d271a9ef6caaf83ffed387
1 file changed +31 -10
gitk
+31 -10
@@ -7612,7 +7612,7 @@ proc resethead {} {
7612 tkwait window $w
7613 if {!$confirm_ok} return
7614 if {[catch {set fd [open \
7615 - [list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
7615 + [list | git reset --$resettype $rowmenuid 2>@1] r]} err]} {
7616 error_popup $err
7617 } else {
7618 dohidelocalchanges
@@ -7674,25 +7674,46 @@ proc cobranch {} {
7674 global showlocalchanges mainheadid
7675
7676 # check the tree is clean first??
7677 - set oldmainhead $mainhead
7677 nowbusy checkout [mc "Checking out"]
7678 update
7679 dohidelocalchanges
7680 if {[catch {
7682 - exec git checkout -q $headmenuhead
7681 + set fd [open [list | git checkout $headmenuhead 2>@1] r]
7682 } err]} {
7683 notbusy checkout
7684 error_popup $err
7685 + if {$showlocalchanges} {
7686 + dodiffindex
7687 + }
7688 } else {
7687 - notbusy checkout
7688 - set mainhead $headmenuhead
7689 - set mainheadid $headmenuid
7690 - if {[info exists headids($oldmainhead)]} {
7691 - redrawtags $headids($oldmainhead)
7689 + filerun $fd [list readcheckoutstat $fd $headmenuhead $headmenuid]
7690 + }
7691 +}
7692 +
7693 +proc readcheckoutstat {fd newhead newheadid} {
7694 + global mainhead mainheadid headids showlocalchanges progresscoords
7695 +
7696 + if {[gets $fd line] >= 0} {
7697 + if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
7698 + set progresscoords [list 0 [expr {1.0 * $m / $n}]]
7699 + adjustprogress
7700 }
7693 - redrawtags $headmenuid
7694 - selbyid $headmenuid
7701 + return 1
7702 + }
7703 + set progresscoords {0 0}
7704 + adjustprogress
7705 + notbusy checkout
7706 + if {[catch {close $fd} err]} {
7707 + error_popup $err
7708 + }
7709 + set oldmainhead $mainhead
7710 + set mainhead $newhead
7711 + set mainheadid $newheadid
7712 + if {[info exists headids($oldmainhead)]} {
7713 + redrawtags $headids($oldmainhead)
7714 }
7715 + redrawtags $newheadid
7716 + selbyid $newheadid
7717 if {$showlocalchanges} {
7718 dodiffindex
7719 }