I'm really starting to dislike global variables. The ui_status_value
global varible is just one of those that seems to appear in a lot of
code and in many cases we didn't even declare it "global" within the
proc that updates it so we haven't always been getting all of the
updates we expected to see.
This change introduces two new global procs:
ui_status $msg; # Sets the status bar to show $msg.
ui_ready; # Changes the status bar to show "Ready."
The second (special) form is used because we often update the area
with this message once we are done processing a block of work and
want the user to know we have completed it.
I'm not fixing the cases that appear in lib/branch.tcl right now
as I'm actually in the middle of a huge refactoring of that code
to support making a detached HEAD checkout.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
@ -58,7 +58,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
@@ -58,7 +58,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
global HEAD commit_type file_states ui_comm repo_config
global ui_status_value pch_error
global pch_error
if {[committer_ident] eq {}} return
if {![lock_index update]} return
@ -132,7 +132,7 @@ Another Git program has modified this repository since the last scan. A rescan
@@ -132,7 +132,7 @@ Another Git program has modified this repository since the last scan. A rescan
The rescan will be automatically started now.
}
unlock_index
rescan {set ui_status_value {Ready.}}
rescan ui_ready
return
}
@ -206,7 +206,7 @@ A good commit message has the following format:
@@ -206,7 +206,7 @@ A good commit message has the following format:
return
}
set ui_status_value {Calling pre-commit hook...}
ui_status {Calling pre-commit hook...}
set pch_error {}
set fd_ph [open "| $pchook" r]
fconfigure $fd_ph -blocking 0 -translation binary
@ -215,13 +215,13 @@ A good commit message has the following format:
@@ -215,13 +215,13 @@ A good commit message has the following format:
}
proc commit_prehook_wait {fd_ph curHEAD msg} {
global pch_error ui_status_value
global pch_error
append pch_error [read $fd_ph]
fconfigure $fd_ph -blocking 1
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
set ui_status_value {Commit declined by pre-commit hook.}
global ui_status_value ui_comm selected_commit_type
global current_branch
global ui_comm selected_commit_type
global file_states selected_paths rescan_active
global repo_config
gets $fd_wt tree_id
if {$tree_id eq {} || [catch {close $fd_wt} err]} {
error_popup "write-tree failed:\n\n$err"
set ui_status_value {Commit failed.}
ui_status {Commit failed.}
unlock_index
return
}
@ -269,7 +267,7 @@ No files were modified by this commit and it was not a merge commit.
@@ -269,7 +267,7 @@ No files were modified by this commit and it was not a merge commit.
A rescan will be automatically started now.
}
unlock_index
rescan {set ui_status_value {No changes to commit.}}
rescan {ui_status {No changes to commit.}}
return
}
}
@ -294,7 +292,7 @@ A rescan will be automatically started now.
@@ -294,7 +292,7 @@ A rescan will be automatically started now.
lappend cmd <$msg_p
if {[catch {set cmt_id [eval git $cmd]} err]} {
error_popup "commit-tree failed:\n\n$err"
set ui_status_value {Commit failed.}
ui_status {Commit failed.}
unlock_index
return
}
@ -316,7 +314,7 @@ A rescan will be automatically started now.
@@ -316,7 +314,7 @@ A rescan will be automatically started now.
git update-ref -m $reflogm HEAD $cmt_id $curHEAD
} err]} {
error_popup "update-ref failed:\n\n$err"
set ui_status_value {Commit failed.}
ui_status {Commit failed.}
unlock_index
return
}
@ -410,6 +408,5 @@ A rescan will be automatically started now.
@@ -410,6 +408,5 @@ A rescan will be automatically started now.
display_all_files
unlock_index
reshow_diff
set ui_status_value \
"Created commit [string range $cmt_id 0 7]: $subject"
ui_status "Created commit [string range $cmt_id 0 7]: $subject"
@ -49,13 +49,13 @@ A rescan will be automatically started to find other files which may have the sa
@@ -49,13 +49,13 @@ A rescan will be automatically started to find other files which may have the sa
clear_diff
display_file $path __
rescan {set ui_status_value {Ready.}} 0
rescan ui_ready 0
}
proc show_diff {path w {lno {}}} {
global file_states file_lists
global is_3way_diff diff_active repo_config
global ui_diff ui_status_value ui_index ui_workdir
global ui_diff ui_index ui_workdir
global current_diff_path current_diff_side current_diff_header
[concat $after {set ui_status_value {Ready to commit.}}]
[concat $after {ui_status {Ready to commit.}}]
}
}
@ -370,7 +370,7 @@ Any unadded changes will be permanently lost by the revert." \
@@ -370,7 +370,7 @@ Any unadded changes will be permanently lost by the revert." \
@ -28,7 +28,7 @@ Another Git program has modified this repository since the last scan. A rescan
@@ -28,7 +28,7 @@ Another Git program has modified this repository since the last scan. A rescan
@ -121,7 +121,7 @@ Please select fewer branches. To merge more than 15 branches, merge the branche
@@ -121,7 +121,7 @@ Please select fewer branches. To merge more than 15 branches, merge the branche
}
set msg "Merging $current_branch, [join $names {, }]"
set ui_status_value "$msg..."
ui_status "$msg..."
set cons [console::new "Merge" $msg]
console::exec $cons $cmd \
[namespace code [list _finish $revcnt $cons]]
@ -150,14 +150,14 @@ You can attempt this merge again by merging only one branch at a time." $w
@@ -150,14 +150,14 @@ You can attempt this merge again by merging only one branch at a time." $w
fconfigure $fd -blocking 0 -translation binary
fileevent $fd readable \
[namespace code [list _reset_wait $fd]]
set ui_status_value {Aborting... please wait...}
ui_status {Aborting... please wait...}
return
}
set msg {Merge failed. Conflict resolution is required.}
}
unlock_index
rescan [list set ui_status_value $msg]
rescan [list ui_status $msg]
}
proc dialog {} {
@ -285,7 +285,7 @@ Continue with aborting the current $op?"] eq {yes}} {
@@ -285,7 +285,7 @@ Continue with aborting the current $op?"] eq {yes}} {