You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.0 KiB
116 lines
3.0 KiB
18 years ago
|
# git-gui object database management support
|
||
|
# Copyright (C) 2006, 2007 Shawn Pearce
|
||
|
|
||
|
proc do_stats {} {
|
||
15 years ago
|
global use_ttk NS
|
||
18 years ago
|
set fd [git_read count-objects -v]
|
||
18 years ago
|
while {[gets $fd line] > 0} {
|
||
|
if {[regexp {^([^:]+): (\d+)$} $line _ name value]} {
|
||
|
set stats($name) $value
|
||
|
}
|
||
|
}
|
||
|
close $fd
|
||
|
|
||
|
set packed_sz 0
|
||
|
foreach p [glob -directory [gitdir objects pack] \
|
||
|
-type f \
|
||
|
-nocomplain -- *] {
|
||
|
incr packed_sz [file size $p]
|
||
|
}
|
||
|
if {$packed_sz > 0} {
|
||
|
set stats(size-pack) [expr {$packed_sz / 1024}]
|
||
|
}
|
||
|
|
||
|
set w .stats_view
|
||
15 years ago
|
Dialog $w
|
||
|
wm withdraw $w
|
||
18 years ago
|
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
|
||
|
|
||
15 years ago
|
${NS}::frame $w.buttons
|
||
|
${NS}::button $w.buttons.close -text [mc Close] \
|
||
18 years ago
|
-default active \
|
||
|
-command [list destroy $w]
|
||
15 years ago
|
${NS}::button $w.buttons.gc -text [mc "Compress Database"] \
|
||
18 years ago
|
-default normal \
|
||
|
-command "destroy $w;do_gc"
|
||
|
pack $w.buttons.close -side right
|
||
|
pack $w.buttons.gc -side left
|
||
|
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
|
||
|
|
||
15 years ago
|
${NS}::labelframe $w.stat -text [mc "Database Statistics"]
|
||
18 years ago
|
foreach s {
|
||
18 years ago
|
{count {mc "Number of loose objects"}}
|
||
|
{size {mc "Disk space used by loose objects"} { KiB}}
|
||
|
{in-pack {mc "Number of packed objects"}}
|
||
|
{packs {mc "Number of packs"}}
|
||
|
{size-pack {mc "Disk space used by packed objects"} { KiB}}
|
||
|
{prune-packable {mc "Packed objects waiting for pruning"}}
|
||
|
{garbage {mc "Garbage files"}}
|
||
18 years ago
|
} {
|
||
|
set name [lindex $s 0]
|
||
18 years ago
|
set label [eval [lindex $s 1]]
|
||
18 years ago
|
if {[catch {set value $stats($name)}]} continue
|
||
|
if {[llength $s] > 2} {
|
||
|
set value "$value[lindex $s 2]"
|
||
|
}
|
||
|
|
||
15 years ago
|
${NS}::label $w.stat.l_$name -text "$label:" -anchor w
|
||
|
${NS}::label $w.stat.v_$name -text $value -anchor w
|
||
18 years ago
|
grid $w.stat.l_$name $w.stat.v_$name -sticky we -padx {0 5}
|
||
|
}
|
||
|
pack $w.stat -pady 10 -padx 10
|
||
|
|
||
|
bind $w <Visibility> "grab $w; focus $w.buttons.close"
|
||
|
bind $w <Key-Escape> [list destroy $w]
|
||
|
bind $w <Key-Return> [list destroy $w]
|
||
18 years ago
|
wm title $w [append "[appname] ([reponame]): " [mc "Database Statistics"]]
|
||
15 years ago
|
wm deiconify $w
|
||
18 years ago
|
tkwait window $w
|
||
|
}
|
||
|
|
||
|
proc do_gc {} {
|
||
18 years ago
|
set w [console::new {gc} [mc "Compressing the object database"]]
|
||
18 years ago
|
console::chain $w {
|
||
|
{exec git pack-refs --prune}
|
||
|
{exec git reflog expire --all}
|
||
|
{exec git repack -a -d -l}
|
||
|
{exec git rerere gc}
|
||
|
}
|
||
18 years ago
|
}
|
||
|
|
||
|
proc do_fsck_objects {} {
|
||
18 years ago
|
set w [console::new {fsck-objects} \
|
||
18 years ago
|
[mc "Verifying the object database with fsck-objects"]]
|
||
18 years ago
|
set cmd [list git fsck-objects]
|
||
|
lappend cmd --full
|
||
|
lappend cmd --cache
|
||
|
lappend cmd --strict
|
||
18 years ago
|
console::exec $w $cmd
|
||
18 years ago
|
}
|
||
18 years ago
|
|
||
|
proc hint_gc {} {
|
||
16 years ago
|
set ndirs 1
|
||
|
set limit 8
|
||
18 years ago
|
if {[is_Windows]} {
|
||
16 years ago
|
set ndirs 4
|
||
|
set limit 1
|
||
18 years ago
|
}
|
||
|
|
||
16 years ago
|
set count [llength [glob \
|
||
18 years ago
|
-nocomplain \
|
||
|
-- \
|
||
16 years ago
|
[gitdir objects 4\[0-[expr {$ndirs-1}]\]/*]]]
|
||
18 years ago
|
|
||
16 years ago
|
if {$count >= $limit * $ndirs} {
|
||
|
set objects_current [expr {$count * 256/$ndirs}]
|
||
18 years ago
|
if {[ask_popup \
|
||
18 years ago
|
[mc "This repository currently has approximately %i loose objects.
|
||
18 years ago
|
|
||
16 years ago
|
To maintain optimal performance it is strongly recommended that you compress the database.
|
||
18 years ago
|
|
||
16 years ago
|
Compress the database now?" $objects_current]] eq yes} {
|
||
18 years ago
|
do_gc
|
||
|
}
|
||
|
}
|
||
|
}
|