Code

Merge branch 'maint'
[git.git] / lib / branch_delete.tcl
index 16ca6938bec5c93f189e3a63eb0c6cd44ed9503b..86c4f73370a76ffa0196be0c58f11092b101cf0b 100644 (file)
@@ -9,37 +9,38 @@ field w_check         ; # revision picker for merge test
 field w_delete        ; # delete button
 
 constructor dialog {} {
-       global all_heads current_branch
+       global current_branch
 
        make_toplevel top w
-       wm title $top "[appname] ([reponame]): Delete Branch"
+       wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
        if {$top ne {.}} {
                wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
        }
 
-       label $w.header -text {Delete Local Branch} -font font_uibold
+       label $w.header -text [mc "Delete Local Branch"] -font font_uibold
        pack $w.header -side top -fill x
 
        frame $w.buttons
        set w_delete $w.buttons.delete
        button $w_delete \
-               -text Delete \
+               -text [mc Delete] \
                -default active \
                -state disabled \
                -command [cb _delete]
        pack $w_delete -side right
        button $w.buttons.cancel \
-               -text {Cancel} \
+               -text [mc Cancel] \
                -command [list destroy $w]
        pack $w.buttons.cancel -side right -padx 5
        pack $w.buttons -side bottom -fill x -pady 10 -padx 10
 
-       labelframe $w.list -text {Local Branches}
+       labelframe $w.list -text [mc "Local Branches"]
        set w_heads $w.list.l
        listbox $w_heads \
                -height 10 \
                -width 70 \
                -selectmode extended \
+               -exportselection false \
                -yscrollcommand [list $w.list.sby set]
        scrollbar $w.list.sby -command [list $w.list.l yview]
        pack $w.list.sby -side right -fill y
@@ -48,12 +49,12 @@ constructor dialog {} {
 
        set w_check [choose_rev::new \
                $w.check \
-               {Delete Only If Merged Into} \
+               [mc "Delete Only If Merged Into"] \
                ]
-       $w_check none {Always (Do not perform merge test.)}
+       $w_check none [mc "Always (Do not perform merge test.)"]
        pack $w.check -anchor nw -fill x -pady 5 -padx 5
 
-       foreach h $all_heads {
+       foreach h [load_all_heads] {
                if {$h ne $current_branch} {
                        $w_heads insert end $h
                }
@@ -78,15 +79,7 @@ method _select {} {
 }
 
 method _delete {} {
-       global all_heads
-
-       if {[catch {set check_cmt [$w_check get_commit]} err]} {
-               tk_messageBox \
-                       -icon error \
-                       -type ok \
-                       -title [wm title $w] \
-                       -parent $w \
-                       -message "Invalid revision: [$w_check get]"
+       if {[catch {set check_cmt [$w_check commit_or_die]}]} {
                return
        }
 
@@ -107,7 +100,7 @@ method _delete {} {
                lappend to_delete [list $b $o]
        }
        if {$not_merged ne {}} {
-               set msg "The following branches are not completely merged into [$w_check get]:
+               set msg "[mc "The following branches are not completely merged into %s:" [$w_check get]]
 
  - [join $not_merged "\n - "]"
                tk_messageBox \
@@ -119,9 +112,7 @@ method _delete {} {
        }
        if {$to_delete eq {}} return
        if {$check_cmt eq {}} {
-               set msg {Recovering deleted branches is difficult.
-
-Delete the selected branches?}
+               set msg [mc "Recovering deleted branches is difficult. \n\n Delete the selected branches?"]
                if {[tk_messageBox \
                        -icon warning \
                        -type yesno \
@@ -138,11 +129,6 @@ Delete the selected branches?}
                set o [lindex $i 1]
                if {[catch {git update-ref -d "refs/heads/$b" $o} err]} {
                        append failed " - $b: $err\n"
-               } else {
-                       set x [lsearch -sorted -exact $all_heads $b]
-                       if {$x >= 0} {
-                               set all_heads [lreplace $all_heads $x $x]
-                       }
                }
        }
 
@@ -152,11 +138,9 @@ Delete the selected branches?}
                        -type ok \
                        -title [wm title $w] \
                        -parent $w \
-                       -message "Failed to delete branches:\n$failed"
+                       -message [mc "Failed to delete branches:\n%s" $failed]
        }
 
-       set all_heads [lsort $all_heads]
-       populate_branch_menu
        destroy $w
 }