summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f6eed2)
raw | patch | inline | side by side (parent: 6f6eed2)
author | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 7 Nov 2006 00:12:58 +0000 (19:12 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 7 Nov 2006 08:05:16 +0000 (03:05 -0500) |
When we are refreshing from the index or updating the index we shouldn't
let the user cause other index based operations to occur as these would
likely conflict with the currently running operations possibly causing
some index changes to be lost.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
let the user cause other index based operations to occur as these would
likely conflict with the currently running operations possibly causing
some index changes to be lost.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui | patch | blob | history |
index 3ee32e105c2f5be814042ff1aea910fea06a76b4..168062e67b54b5e3dbb57f282e2f68d303368909 100755 (executable)
--- a/git-gui
+++ b/git-gui
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
-
######################################################################
##
-## status
+## task management
set status_active 0
set diff_active 0
set checkin_active 0
set update_index_fd {}
-proc is_busy {} {
- global status_active diff_active checkin_active update_index_fd
+set disable_on_lock [list]
+set index_lock_type none
+
+proc lock_index {type} {
+ global index_lock_type disable_on_lock
- if {$status_active > 0
- || $diff_active
- || $checkin_active
- || $update_index_fd != {}} {
+ if {$index_lock_type == {none}} {
+ set index_lock_type $type
+ foreach w $disable_on_lock {
+ uplevel #0 $w disabled
+ }
+ return 1
+ } elseif {$index_lock_type == {begin-update} && $type == {update}} {
+ set index_lock_type $type
return 1
}
return 0
}
+proc unlock_index {} {
+ global index_lock_type disable_on_lock
+
+ set index_lock_type none
+ foreach w $disable_on_lock {
+ uplevel #0 $w normal
+ }
+}
+
+######################################################################
+##
+## status
+
proc update_status {} {
global gitdir HEAD commit_type
global ui_index ui_other ui_status_value ui_comm
global status_active file_states
- if {[is_busy]} return
+ if {$status_active || ![lock_index read]} return
array unset file_states
foreach w [list $ui_index $ui_other] {
set $buf {}
close $fd
if {[incr status_active -1] == 0} {
+ unlock_index
set ui_status_value {Ready.}
if {$ui_fname_value != {}} {
show_diff $ui_fname_value
global file_states HEAD diff_3way diff_active
global ui_diff ui_fname_value ui_fstatus_value ui_status_value
- if {[is_busy]} return
+ if {$diff_active || ![lock_index read]} return
clear_diff
set s $file_states($path)
close $fd
} err ]} {
set diff_active 0
+ unlock_index
set ui_status_value "Unable to display $path"
error_popup "Error loading file:\n$err"
return
if {[catch {set fd [open $cmd r]} err]} {
set diff_active 0
+ unlock_index
set ui_status_value "Unable to display $path"
error_popup "Error loading diff:\n$err"
return
if {[eof $fd]} {
close $fd
set diff_active 0
+ unlock_index
set ui_status_value {Ready.}
}
}
global update_index_fd
if {$update_index_fd == {}} {
+ if {![lock_index update]} return
set update_index_fd [open \
"| git update-index --add --remove -z --stdin" \
w]
uplevel 1 $body
close $update_index_fd
set update_index_fd {}
+ unlock_index
} else {
uplevel 1 $body
}
##
## ui commands
+set starting_gitk_msg {Please wait... Starting gitk...}
proc do_gitk {} {
- global tcl_platform ui_status_value
+ global tcl_platform ui_status_value starting_gitk_msg
+
+ set ui_status_value $starting_gitk_msg
+ after 5000 {
+ if {$ui_status_value == $starting_gitk_msg} {
+ set ui_status_value {Ready.}
+ }
+ }
- set ui_status_value "Please wait... Starting gitk..."
if {$tcl_platform(platform) == "windows"} {
exec sh -c gitk &
} else {
proc do_checkin_all {} {
global checkin_active ui_status_value
- if {[is_busy]} return
+ if {$checkin_active || ![lock_index begin-update]} return
set checkin_active 1
set ui_status_value {Checking in all files...}
set path [$w get $lno.1 $lno.end]
if {$path == {}} return
- if {$col == 0 && ![is_busy]} {
+ if {$col == 0} {
toggle_mode $path
}
}
set difffont {Courier 10}
set maincursor [. cget -cursor]
+switch -- $tcl_platform(platform) {
+windows {set M1B Control; set M1T Ctrl}
+default {set M1B M1; set M1T M1}
+}
+
# -- Menu Bar
menu .mbar -tearoff 0
.mbar add cascade -label Project -menu .mbar.project
-font $mainfont
.mbar.project add command -label Quit \
-command do_quit \
+ -accelerator $M1T-Q \
-font $mainfont
# -- Commit Menu
menu .mbar.commit
.mbar.commit add command -label Rescan \
-command do_rescan \
+ -accelerator F5 \
-font $mainfont
+lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
.mbar.commit add command -label {Check-in All Files} \
-command do_checkin_all \
+ -accelerator $M1T-U \
-font $mainfont
+lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
.mbar.commit add command -label {Sign Off} \
-command do_signoff \
+ -accelerator $M1T-S \
-font $mainfont
.mbar.commit add command -label Commit \
-command do_commit \
+ -accelerator $M1T-Return \
-font $mainfont
+lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
# -- Fetch Menu
menu .mbar.fetch
-command do_rescan \
-font $mainfont
pack .vpane.commarea.buttons.rescan -side top -fill x
+lappend disable_on_lock {.vpane.commarea.buttons.rescan conf -state}
button .vpane.commarea.buttons.ciall -text {Check-in All} \
-command do_checkin_all \
-font $mainfont
pack .vpane.commarea.buttons.ciall -side top -fill x
+lappend disable_on_lock {.vpane.commarea.buttons.ciall conf -state}
button .vpane.commarea.buttons.signoff -text {Sign Off} \
-command do_signoff \
-command do_commit \
-font $mainfont
pack .vpane.commarea.buttons.commit -side top -fill x
+lappend disable_on_lock {.vpane.commarea.buttons.commit conf -state}
# -- Commit Message Buffer
frame .vpane.commarea.buffer
# -- Key Bindings
bind . <Destroy> do_quit
bind . <Key-F5> do_rescan
-bind . <M1-Key-r> do_rescan
-bind . <M1-Key-R> do_rescan
-bind . <M1-Key-s> do_signoff
-bind . <M1-Key-S> do_signoff
-bind . <M1-Key-u> do_checkin_all
-bind . <M1-Key-U> do_checkin_all
-bind . <M1-Key-Return> do_commit
-bind . <M1-Key-q> do_quit
-bind . <M1-Key-Q> do_quit
+bind . <$M1B-Key-r> do_rescan
+bind . <$M1B-Key-R> do_rescan
+bind . <$M1B-Key-s> do_signoff
+bind . <$M1B-Key-S> do_signoff
+bind . <$M1B-Key-u> do_checkin_all
+bind . <$M1B-Key-U> do_checkin_all
+bind . <$M1B-Key-Return> do_commit
+bind . <$M1B-Key-q> do_quit
+bind . <$M1B-Key-Q> do_quit
foreach i [list $ui_index $ui_other] {
bind $i <Button-1> {click %W %x %y 1 %X %Y; break}
bind $i <Button-3> {click %W %x %y 3 %X %Y; break}
bind $i <ButtonRelease-1> {unclick %W %x %y; break}
}
-unset i
+unset i M1B M1T
######################################################################
##