From: Shawn O. Pearce Date: Sun, 21 Oct 2007 00:43:36 +0000 (-0400) Subject: Merge branch 'maint' X-Git-Tag: gitgui-0.9.0~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c9dcc7f865fb7891f4f6d068230663eb2cb586a7?ds=inline;hp=-c Merge branch 'maint' * maint: git-gui: Don't display CR within console windows git-gui: Handle progress bars from newer gits git-gui: Correctly report failures from git-write-tree Conflicts: lib/commit.tcl lib/console.tcl --- c9dcc7f865fb7891f4f6d068230663eb2cb586a7 diff --combined lib/commit.tcl index 7099f5c6f7,57238129e4..10b0430f54 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@@ -6,19 -6,19 +6,19 @@@ proc load_last_commit {} global repo_config if {[llength $PARENT] == 0} { - error_popup {There is nothing to amend. + error_popup [mc "There is nothing to amend. You are about to create the initial commit. There is no commit before this to amend. -} +"] return } repository_state curType curHEAD curMERGE_HEAD if {$curType eq {merge}} { - error_popup {Cannot amend while merging. + error_popup [mc "Cannot amend while merging. You are currently in the middle of a merge that has not been fully completed. You cannot amend the prior commit unless you first abort the current merge activity. -} +"] return } @@@ -46,7 -46,7 +46,7 @@@ } set msg [string trim $msg] } err]} { - error_popup "Error loading commit data for amend:\n\n$err" + error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"] return } @@@ -73,12 -73,12 +73,12 @@@ proc committer_ident {} if {$GIT_COMMITTER_IDENT eq {}} { if {[catch {set me [git var GIT_COMMITTER_IDENT]} err]} { - error_popup "Unable to obtain your identity:\n\n$err" + error_popup [strcat [mc "Unable to obtain your identity:"] "\n\n$err"] return {} } if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \ $me me GIT_COMMITTER_IDENT]} { - error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me" + error_popup [strcat [mc "Invalid GIT_COMMITTER_IDENT:"] "\n\n$me"] return {} } } @@@ -130,12 -130,12 +130,12 @@@ proc commit_tree {} && $curType eq {normal} && $curHEAD eq $HEAD} { } elseif {$commit_type ne $curType || $HEAD ne $curHEAD} { - info_popup {Last scanned state does not match repository state. + info_popup [mc "Last scanned state does not match repository state. Another Git program has modified this repository since the last scan. A rescan must be performed before another commit can be created. The rescan will be automatically started now. -} +"] unlock_index rescan ui_ready return @@@ -151,26 -151,26 +151,26 @@@ D? - M? {set files_ready 1} U? { - error_popup "Unmerged files cannot be committed. + error_popup [mc "Unmerged files cannot be committed. -File [short_path $path] has merge conflicts. You must resolve them and stage the file before committing. -" +File %s has merge conflicts. You must resolve them and stage the file before committing. +" [short_path $path]] unlock_index return } default { - error_popup "Unknown file state [lindex $s 0] detected. + error_popup [mc "Unknown file state %s detected. -File [short_path $path] cannot be committed by this program. -" +File %s cannot be committed by this program. +" [lindex $s 0] [short_path $path]] } } } if {!$files_ready && ![string match *merge $curType]} { - info_popup {No changes to commit. + info_popup [mc "No changes to commit. You must stage at least 1 file before you can commit. -} +"] unlock_index return } @@@ -180,14 -180,14 +180,14 @@@ set msg [string trim [$ui_comm get 1.0 end]] regsub -all -line {[ \t\r]+$} $msg {} msg if {$msg eq {}} { - error_popup {Please supply a commit message. + error_popup [mc "Please supply a commit message. A good commit message has the following format: - First line: Describe in one sentance what you did. - Second line: Blank - Remaining lines: Describe why this change is good. -} +"] unlock_index return } @@@ -253,8 -253,8 +253,8 @@@ proc commit_committree {fd_wt curHEAD m global repo_config gets $fd_wt tree_id - if {$tree_id eq {} || [catch {close $fd_wt} err]} { + if {[catch {close $fd_wt} err]} { - error_popup "write-tree failed:\n\n$err" + error_popup [strcat [mc "write-tree failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return @@@ -272,18 -272,18 +272,18 @@@ && [string length $old_tree] == 45} { set old_tree [string range $old_tree 5 end] } else { - error "Commit $PARENT appears to be corrupt" + error [mc "Commit %s appears to be corrupt" $PARENT] } if {$tree_id eq $old_tree} { - info_popup {No changes to commit. + info_popup [mc "No changes to commit. No files were modified by this commit and it was not a merge commit. A rescan will be automatically started now. -} +"] unlock_index - rescan {ui_status {No changes to commit.}} + rescan {ui_status [mc "No changes to commit."]} return } } @@@ -300,7 -300,7 +300,7 @@@ if {$use_enc ne {}} { fconfigure $msg_wt -encoding $use_enc } else { - puts stderr "warning: Tcl does not support encoding '$enc'." + puts stderr [mc "warning: Tcl does not support encoding '%s'." $enc] fconfigure $msg_wt -encoding utf-8 } puts -nonewline $msg_wt $msg @@@ -314,7 -314,7 +314,7 @@@ } lappend cmd <$msg_p if {[catch {set cmt_id [eval git $cmd]} err]} { - error_popup "commit-tree failed:\n\n$err" + error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return @@@ -336,7 -336,7 +336,7 @@@ if {[catch { git update-ref -m $reflogm HEAD $cmt_id $curHEAD } err]} { - error_popup "update-ref failed:\n\n$err" + error_popup [strcat [mc "update-ref failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return @@@ -427,5 -427,5 +427,5 @@@ display_all_files unlock_index reshow_diff - ui_status "Created commit [string range $cmt_id 0 7]: $subject" + ui_status [mc "Created commit %s: %s" [string range $cmt_id 0 7] $subject] } diff --combined lib/console.tcl index 2075374683,b038a78358..5597188d80 --- a/lib/console.tcl +++ b/lib/console.tcl @@@ -6,7 -6,6 +6,7 @@@ class console field t_short field t_long field w +field w_t field console_cr field is_toplevel 1; # are we our own window? @@@ -37,7 -36,6 +37,7 @@@ method _init {} } set console_cr 1.0 + set w_t $w.m.t frame $w.m label $w.m.l1 \ @@@ -45,47 -43,51 +45,47 @@@ -anchor w \ -justify left \ -font font_uibold - text $w.m.t \ + text $w_t \ -background white -borderwidth 1 \ -relief sunken \ -width 80 -height 10 \ -wrap none \ -font font_diff \ -state disabled \ - -xscrollcommand [list $w.m.sbx set] \ - -yscrollcommand [list $w.m.sby set] - label $w.m.s -text {Working... please wait...} \ + -xscrollcommand [cb _sb_set $w.m.sbx h] \ + -yscrollcommand [cb _sb_set $w.m.sby v] + label $w.m.s -text [mc "Working... please wait..."] \ -anchor w \ -justify left \ -font font_uibold - scrollbar $w.m.sbx -command [list $w.m.t xview] -orient h - scrollbar $w.m.sby -command [list $w.m.t yview] pack $w.m.l1 -side top -fill x pack $w.m.s -side bottom -fill x - pack $w.m.sbx -side bottom -fill x - pack $w.m.sby -side right -fill y - pack $w.m.t -side left -fill both -expand 1 + pack $w_t -side left -fill both -expand 1 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10 menu $w.ctxm -tearoff 0 - $w.ctxm add command -label "Copy" \ - -command "tk_textCopy $w.m.t" - $w.ctxm add command -label "Select All" \ - -command "focus $w.m.t;$w.m.t tag add sel 0.0 end" - $w.ctxm add command -label "Copy All" \ + $w.ctxm add command -label [mc "Copy"] \ + -command "tk_textCopy $w_t" + $w.ctxm add command -label [mc "Select All"] \ + -command "focus $w_t;$w_t tag add sel 0.0 end" + $w.ctxm add command -label [mc "Copy All"] \ -command " - $w.m.t tag add sel 0.0 end - tk_textCopy $w.m.t - $w.m.t tag remove sel 0.0 end + $w_t tag add sel 0.0 end + tk_textCopy $w_t + $w_t tag remove sel 0.0 end " if {$is_toplevel} { - button $w.ok -text {Close} \ + button $w.ok -text [mc "Close"] \ -state disabled \ -command [list destroy $w] pack $w.ok -side bottom -anchor e -pady 10 -padx 10 bind $w [list focus $w] } - bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y" - bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break" - bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break" + bind_button3 $w_t "tk_popup $w.ctxm %X %Y" + bind $w_t <$M1B-Key-a> "$w_t tag add sel 0.0 end;break" + bind $w_t <$M1B-Key-A> "$w_t tag add sel 0.0 end;break" } method exec {cmd {after {}}} { @@@ -102,8 -104,8 +102,8 @@@ method _read {fd after} { set buf [read $fd] if {$buf ne {}} { - if {![winfo exists $w.m.t]} {_init $this} - $w.m.t conf -state normal + if {![winfo exists $w_t]} {_init $this} + $w_t conf -state normal set c 0 set n [string length $buf] while {$c < $n} { @@@ -113,20 -115,20 +113,20 @@@ if {$lf < 0} {set lf [expr {$n + 1}]} if {$lf < $cr} { - $w.m.t insert end [string range $buf $c $lf] - set console_cr [$w.m.t index {end -1c}] + $w_t insert end [string range $buf $c $lf] + set console_cr [$w_t index {end -1c}] set c $lf incr c } else { - $w.m.t delete $console_cr end - $w.m.t insert end "\n" - $w.m.t insert end [string range $buf $c [expr {$cr - 1}]] + $w_t delete $console_cr end + $w_t insert end "\n" - $w_t insert end [string range $buf $c $cr] ++ $w_t insert end [string range $buf $c [expr {$cr - 1}]] set c $cr incr c } } - $w.m.t conf -state disabled - $w.m.t see end + $w_t conf -state disabled + $w_t see end } fconfigure $fd -blocking 1 @@@ -169,50 -171,33 +169,50 @@@ method chain {cmdlist {ok 1}} } method insert {txt} { - if {![winfo exists $w.m.t]} {_init $this} - $w.m.t conf -state normal - $w.m.t insert end "$txt\n" - set console_cr [$w.m.t index {end -1c}] - $w.m.t conf -state disabled + if {![winfo exists $w_t]} {_init $this} + $w_t conf -state normal + $w_t insert end "$txt\n" + set console_cr [$w_t index {end -1c}] + $w_t conf -state disabled } method done {ok} { if {$ok} { if {[winfo exists $w.m.s]} { - $w.m.s conf -background green -text {Success} + bind $w.m.s [list delete_this $this] + $w.m.s conf -background green -text [mc "Success"] if {$is_toplevel} { $w.ok conf -state normal focus $w.ok } + } else { + delete_this } } else { if {![winfo exists $w.m.s]} { _init $this } - $w.m.s conf -background red -text {Error: Command Failed} + bind $w.m.s [list delete_this $this] + $w.m.s conf -background red -text [mc "Error: Command Failed"] if {$is_toplevel} { $w.ok conf -state normal focus $w.ok } } - delete_this +} + +method _sb_set {sb orient first last} { + if {![winfo exists $sb]} { + if {$first == $last || ($first == 0 && $last == 1)} return + if {$orient eq {h}} { + scrollbar $sb -orient h -command [list $w_t xview] + pack $sb -fill x -side bottom -before $w_t + } else { + scrollbar $sb -orient v -command [list $w_t yview] + pack $sb -fill y -side right -before $w_t + } + } + $sb set $first $last } } diff --combined lib/status_bar.tcl index 5c5bf7c731,3bf79eb6e0..51d4177551 --- a/lib/status_bar.tcl +++ b/lib/status_bar.tcl @@@ -6,7 -6,6 +6,7 @@@ class status_bar field w ; # our own window path field w_l ; # text widget we draw messages into field w_c ; # canvas we draw a progress bar into +field c_pack ; # script to pack the canvas with field status {}; # single line of text we show field prefix {}; # text we format into status field units {}; # unit of progress @@@ -25,29 -24,6 +25,29 @@@ constructor new {path} -anchor w \ -justify left pack $w_l -side left + set c_pack [cb _oneline_pack] + + bind $w [cb _delete %W] + return $this +} + +method _oneline_pack {} { + $w_c conf -width 100 + pack $w_c -side right +} + +constructor two_line {path} { + set w $path + set w_l $w.l + set w_c $w.c + + frame $w + label $w_l \ + -textvariable @status \ + -anchor w \ + -justify left + pack $w_l -anchor w -fill x + set c_pack [list pack $w_c -fill x] bind $w [cb _delete %W] return $this @@@ -58,12 -34,13 +58,12 @@@ method start {msg uds} $w_c coords bar 0 0 0 20 } else { canvas $w_c \ - -width 100 \ -height [expr {int([winfo reqheight $w_l] * 0.6)}] \ -borderwidth 1 \ -relief groove \ -highlightt 0 $w_c create rectangle 0 0 0 20 -tags bar -fill navy - pack $w_c -side right + eval $c_pack } set status $msg @@@ -76,16 -53,11 +76,16 @@@ method update {have total} set pdone 0 if {$total > 0} { set pdone [expr {100 * $have / $total}] + set cdone [expr {[winfo width $w_c] * $have / $total}] } - set status [format "%s ... %i of %i %s (%2i%%)" \ - $prefix $have $total $units $pdone] - $w_c coords bar 0 0 $pdone 20 + set prec [string length [format %i $total]] + set status [mc "%s ... %*i of %*i %s (%3i%%)" \ + $prefix \ + $prec $have \ + $prec $total \ + $units $pdone] + $w_c coords bar 0 0 $cdone 20 } method update_meter {buf} { @@@ -97,7 -69,10 +97,10 @@@ set prior [string range $meter 0 $r] set meter [string range $meter [expr {$r + 1}] end] - if {[regexp "\\((\\d+)/(\\d+)\\)\\s+done\r\$" $prior _j a b]} { + set p "\\((\\d+)/(\\d+)\\)" + if {[regexp ":\\s*\\d+% $p\(?:, done.\\s*\n|\\s*\r)\$" $prior _j a b]} { + update $this $a $b + } elseif {[regexp "$p\\s+done\r\$" $prior _j a b]} { update $this $a $b } }