summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 311e02a)
raw | patch | inline | side by side (parent: 311e02a)
author | Shawn O. Pearce <spearce@spearce.org> | |
Fri, 6 Jul 2007 03:16:13 +0000 (23:16 -0400) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Mon, 9 Jul 2007 01:12:57 +0000 (21:12 -0400) |
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>
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>
git-gui.sh | patch | blob | history | |
lib/commit.tcl | patch | blob | history | |
lib/diff.tcl | patch | blob | history | |
lib/index.tcl | patch | blob | history | |
lib/merge.tcl | patch | blob | history |
diff --git a/git-gui.sh b/git-gui.sh
index 516bd972ec111ecb8a323efa43f0473ab503b1fb..88ef64337adb54f06bd8babd9d91ec9ab47e5cec 100755 (executable)
--- a/git-gui.sh
+++ b/git-gui.sh
proc rescan {after {honor_trustmtime 1}} {
global HEAD PARENT MERGE_HEAD commit_type
- global ui_index ui_workdir ui_status_value ui_comm
+ global ui_index ui_workdir ui_comm
global rescan_active file_states
global repo_config
rescan_stage2 {} $after
} else {
set rescan_active 1
- set ui_status_value {Refreshing file status...}
+ ui_status {Refreshing file status...}
set cmd [list git update-index]
lappend cmd -q
lappend cmd --unmerged
}
proc rescan_stage2 {fd after} {
- global ui_status_value
global rescan_active buf_rdi buf_rdf buf_rlo
if {$fd ne {}} {
set buf_rlo {}
set rescan_active 3
- set ui_status_value {Scanning for modified files ...}
+ ui_status {Scanning for modified files ...}
set fd_di [open "| git diff-index --cached -z [PARENT]" r]
set fd_df [open "| git diff-files -z" r]
set fd_lo [open $ls_others r]
return $r
}
+proc ui_status {msg} {
+ set ::ui_status_value $msg
+}
+
+proc ui_ready {{test {}}} {
+ if {$test eq {} || $::ui_status_value eq $test} {
+ ui_status Ready.
+ }
+}
+
proc escape_path {path} {
regsub -all {\\} $path "\\\\" path
regsub -all "\n" $path "\\n" path
set starting_gitk_msg {Starting gitk... please wait...}
proc do_gitk {revs} {
- global env ui_status_value starting_gitk_msg
+ global env starting_gitk_msg
# -- Always start gitk through whatever we were loaded with. This
# lets us bypass using shell process on Windows systems.
error_popup "Unable to start gitk:\n\n$exe does not exist"
} else {
eval exec $cmd &
- set ui_status_value $starting_gitk_msg
+ ui_status $starting_gitk_msg
after 10000 {
- if {$ui_status_value eq $starting_gitk_msg} {
- set ui_status_value {Ready.}
- }
+ ui_ready $starting_gitk_msg
}
}
}
}
proc do_rescan {} {
- rescan {set ui_status_value {Ready.}}
+ rescan ui_ready
}
proc do_commit {} {
update_indexinfo \
"Unstaging [short_path $path] from commit" \
[list $path] \
- [concat $after {set ui_status_value {Ready.}}]
+ [concat $after [list ui_ready]]
} elseif {$w eq $ui_workdir} {
update_index \
"Adding [short_path $path]" \
[list $path] \
- [concat $after {set ui_status_value {Ready.}}]
+ [concat $after [list ui_ready]]
}
} else {
show_diff $path $w $lno
#
if {[is_Cygwin] && [file exists /usr/local/miga/lib/gui-miga]} {
proc do_miga {} {
- global ui_status_value
if {![lock_index update]} return
set cmd [list sh --login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
set miga_fd [open "|$cmd" r]
fconfigure $miga_fd -blocking 0
fileevent $miga_fd readable [list miga_done $miga_fd]
- set ui_status_value {Running miga...}
+ ui_status {Running miga...}
}
proc miga_done {fd} {
read $fd 512
if {[eof $fd]} {
close $fd
unlock_index
- rescan [list set ui_status_value {Ready.}]
+ rescan ui_ready
}
}
.mbar add cascade -label Tools -menu .mbar.tools
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 0de2a28fa5e031bd6c3a090f9288527aed78b188..c5f608beb03a84aac19475adff0fc3f479995f3a 100644 (file)
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
$ui_comm insert end $msg
$ui_comm edit reset
$ui_comm edit modified false
- rescan {set ui_status_value {Ready.}}
+ rescan ui_ready
}
set GIT_COMMITTER_IDENT {}
$ui_comm delete 0.0 end
$ui_comm edit reset
$ui_comm edit modified false
- rescan {set ui_status_value {Ready.}}
+ rescan ui_ready
}
proc commit_tree {} {
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
The rescan will be automatically started now.
}
unlock_index
- rescan {set ui_status_value {Ready.}}
+ rescan ui_ready
return
}
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
}
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.}
+ ui_status {Commit declined by pre-commit hook.}
hook_failed_popup pre-commit $pch_error
unlock_index
} else {
}
proc commit_writetree {curHEAD msg} {
- global ui_status_value
-
- set ui_status_value {Committing changes...}
+ ui_status {Committing changes...}
set fd_wt [open "| git write-tree" r]
fileevent $fd_wt readable \
[list commit_committree $fd_wt $curHEAD $msg]
proc commit_committree {fd_wt curHEAD msg} {
global HEAD PARENT MERGE_HEAD commit_type
- global all_heads current_branch
- 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
}
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
}
}
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
}
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
}
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"
}
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 29436b50cb351f88b1ebde20620729f210c37933..05bf75179bdc04cc31e887f9d0817524db8a1cf4 100644 (file)
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
}
proc reshow_diff {} {
- global ui_status_value file_states file_lists
+ global file_states file_lists
global current_diff_path current_diff_side
set p $current_diff_path
@@ -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
if {$diff_active || ![lock_index read]} return
set current_diff_path $path
set current_diff_side $w
set current_diff_header {}
- set ui_status_value "Loading diff of [escape_path $path]..."
+ ui_status "Loading diff of [escape_path $path]..."
# - Git won't give us the diff, there's nothing to compare to!
#
} err ]} {
set diff_active 0
unlock_index
- set ui_status_value "Unable to display [escape_path $path]"
+ ui_status "Unable to display [escape_path $path]"
error_popup "Error loading file:\n\n$err"
return
}
$ui_diff conf -state disabled
set diff_active 0
unlock_index
- set ui_status_value {Ready.}
+ ui_ready
return
}
if {[catch {set fd [open $cmd r]} err]} {
set diff_active 0
unlock_index
- set ui_status_value "Unable to display [escape_path $path]"
+ ui_status "Unable to display [escape_path $path]"
error_popup "Error loading diff:\n\n$err"
return
}
}
proc read_diff {fd} {
- global ui_diff ui_status_value diff_active
+ global ui_diff diff_active
global is_3way_diff current_diff_header
$ui_diff conf -state normal
close $fd
set diff_active 0
unlock_index
- set ui_status_value {Ready.}
+ ui_ready
if {[$ui_diff index end] eq {2.0}} {
handle_empty_diff
diff --git a/lib/index.tcl b/lib/index.tcl
index 42742850eef627262844d2414a593a6e8952d08a..7c175a96a6d9d66f16ba0a7dd05e6bfd01df7d84 100644 (file)
--- a/lib/index.tcl
+++ b/lib/index.tcl
# Copyright (C) 2006, 2007 Shawn Pearce
proc update_indexinfo {msg pathList after} {
- global update_index_cp ui_status_value
+ global update_index_cp
if {![lock_index update]} return
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
}
proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
- global update_index_cp ui_status_value
+ global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
display_file $path $new
}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
}
proc update_index {msg pathList after} {
- global update_index_cp ui_status_value
+ global update_index_cp
if {![lock_index update]} return
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
}
proc write_update_index {fd pathList totalCnt batch msg after} {
- global update_index_cp ui_status_value
+ global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
display_file $path $new
}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
}
proc checkout_index {msg pathList after} {
- global update_index_cp ui_status_value
+ global update_index_cp
if {![lock_index update]} return
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
}
proc write_checkout_index {fd pathList totalCnt batch msg after} {
- global update_index_cp ui_status_value
+ global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
}
}
- set ui_status_value [format \
+ ui_status [format \
"$msg... %i/%i files (%.2f%%)" \
$update_index_cp \
$totalCnt \
update_indexinfo \
$txt \
$pathList \
- [concat $after {set ui_status_value {Ready.}}]
+ [concat $after [list ui_ready]]
}
}
update_index \
$txt \
$pathList \
- [concat $after {set ui_status_value {Ready to commit.}}]
+ [concat $after {ui_status {Ready to commit.}}]
}
}
checkout_index \
$txt \
$pathList \
- [concat $after {set ui_status_value {Ready.}}]
+ [concat $after [list ui_ready]]
} else {
unlock_index
}
diff --git a/lib/merge.tcl b/lib/merge.tcl
index 889182f5454ac0f636fc57c31a16331c097b0c71..f0a02ea2288976e03dad1de9fd22d4b11e403382 100644 (file)
--- a/lib/merge.tcl
+++ b/lib/merge.tcl
The rescan will be automatically started now.
}
unlock_index
- rescan {set ui_status_value {Ready.}}
+ rescan ui_ready
return 0
}
}
proc _start {w list} {
- global HEAD ui_status_value current_branch
+ global HEAD current_branch
set cmd [list git merge]
set names [_refs $w $list]
}
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]]
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 {} {
set fd [open "| git read-tree --reset -u HEAD" r]
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...}
} else {
unlock_index
}
catch {file delete [gitdir MERGE_MSG]}
catch {file delete [gitdir GITGUI_MSG]}
- rescan {set ui_status_value {Abort completed. Ready.}}
+ rescan {ui_status {Abort completed. Ready.}}
}
}