git-gui: Keep the UI responsive while counting objects in clone
If we are doing a "standard" clone by way of hardlinking the objects (or copying them if hardlinks are not available) the UI can freeze up for a good few seconds while Tcl scans all of the object directories. This is espeically noticed on a Windows system when you are working off network shares and need to wait for both the NT overheads and the network. We now show a progress bar as we count the objects and build our list of things to copy. This keeps the user amused and also makes sure we run the Tk event loop often enough that the window can still be dragged around the desktop. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Sep 24, 2007 at 08:40 UTC
81d4d3dddc5e96aea45a2623c9b1840491348b92
1 file changed
+25
-5
lib/choose_repository.tcl
+25
-5
@@ -462,20 +462,42 @@ method _do_clone2 {} {
462
463
switch -exact -- $clone_type {
464
hardlink {
465
+ set o_cons [status_bar::new $w_body]
466
+ pack $w_body -fill x -padx 10
467
+
468
+ $o_cons start \
469
+ [mc "Counting objects"] \
470
+ [mc "buckets"]
471
+ update
472
+
473
set tolink [list]
474
+ set buckets [glob \
475
+ -tails \
476
+ -nocomplain \
477
+ -directory [file join $objdir] ??]
478
+ set bcnt [expr {[llength $buckets] + 2}]
479
+ set bcur 1
480
+ $o_cons update $bcur $bcnt
481
+ update
482
+
483
file mkdir [file join .git objects pack]
484
foreach i [glob -tails -nocomplain \
485
-directory [file join $objdir pack] *] {
486
lappend tolink [file join pack $i]
487
}
471
- foreach i [glob -tails -nocomplain \
472
- -directory [file join $objdir] ??] {
488
+ $o_cons update [incr bcur] $bcnt
489
+ update
490
+
491
+ foreach i $buckets {
492
file mkdir [file join .git objects $i]
493
foreach j [glob -tails -nocomplain \
494
-directory [file join $objdir $i] *] {
495
lappend tolink [file join $i $j]
496
}
497
+ $o_cons update [incr bcur] $bcnt
498
+ update
499
}
500
+ $o_cons stop
501
502
if {$tolink eq {}} {
503
info_popup [strcat \
@@ -483,13 +505,11 @@ method _do_clone2 {} {
505
"\n" \
506
[mc "The 'master' branch has not been initialized."] \
507
]
508
+ destroy $w_body
509
set done 1
510
return
511
}
512
490
- set o_cons [status_bar::new $w_body]
491
- pack $w_body -fill x -padx 10
492
-
513
set i [lindex $tolink 0]
514
if {[catch {
515
file link -hard \