git-gui: Move merge support into a namespace
Like the console procs I have moved the code related to merge support into their own namespace, so that they are isolated from the rest of the world. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
May 2, 2007 at 13:56 UTC
a6c9b081b6860816615e84b75bbc7916aab184e9
2 files changed
+21
-16
git-gui.sh
+3
-3
@@ -1376,7 +1376,7 @@ if {[is_enabled branch]} {
1376
[.mbar.branch index last] -state]
1377
1378
.mbar.branch add command -label {Reset...} \
1379
- -command do_reset_hard
1379
+ -command merge::reset_hard
1380
lappend disable_on_lock [list .mbar.branch entryconf \
1381
[.mbar.branch index last] -state]
1382
}
@@ -1449,11 +1449,11 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
1449
if {[is_enabled branch]} {
1450
menu .mbar.merge
1451
.mbar.merge add command -label {Local Merge...} \
1452
- -command do_local_merge
1452
+ -command merge::dialog
1453
lappend disable_on_lock \
1454
[list .mbar.merge entryconf [.mbar.merge index last] -state]
1455
.mbar.merge add command -label {Abort Merge...} \
1456
- -command do_reset_hard
1456
+ -command merge::reset_hard
1457
lappend disable_on_lock \
1458
[list .mbar.merge entryconf [.mbar.merge index last] -state]
1459
lib/merge.tcl
+18
-13
@@ -1,7 +1,9 @@
1
# git-gui branch merge support
2
# Copyright (C) 2006, 2007 Shawn Pearce
3
4
-proc can_merge {} {
4
+namespace eval merge {
5
+
6
+proc _can_merge {} {
7
global HEAD commit_type file_states
8
9
if {[string match amend* $commit_type]} {
@@ -61,7 +63,7 @@ You should complete the current commit before starting a merge. Doing so will h
63
return 1
64
}
65
64
-proc visualize_local_merge {w} {
66
+proc _visualize {w} {
67
set revs {}
68
foreach i [$w.source.l curselection] {
69
lappend revs [$w.source.l get $i]
@@ -71,7 +73,7 @@ proc visualize_local_merge {w} {
73
do_gitk $revs
74
}
75
74
-proc start_local_merge_action {w} {
76
+proc _start {w} {
77
global HEAD ui_status_value current_branch
78
79
set cmd [list git merge]
@@ -121,12 +123,12 @@ Please select fewer branches. To merge more than 15 branches, merge the branche
123
set msg "Merging $current_branch, [join $names {, }]"
124
set ui_status_value "$msg..."
125
set cons [console::new "Merge" $msg]
124
- console::exec $cons $cmd [list finish_merge $revcnt]
126
+ console::exec $cons $cmd [namespace code [list _finish $revcnt]]
127
bind $w <Destroy> {}
128
destroy $w
129
}
130
129
-proc finish_merge {revcnt w ok} {
131
+proc _finish {revcnt w ok} {
132
console::done $w $ok
133
if {$ok} {
134
set msg {Merge completed successfully.}
@@ -144,7 +146,8 @@ You can attempt this merge again by merging only one branch at a time." $w
146
147
set fd [open "| git read-tree --reset -u HEAD" r]
148
fconfigure $fd -blocking 0 -translation binary
147
- fileevent $fd readable [list reset_hard_wait $fd]
149
+ fileevent $fd readable \
150
+ [namespace code [list _reset_wait $fd]]
151
set ui_status_value {Aborting... please wait...}
152
return
153
}
@@ -155,10 +158,10 @@ You can attempt this merge again by merging only one branch at a time." $w
158
rescan [list set ui_status_value $msg]
159
}
160
158
-proc do_local_merge {} {
161
+proc dialog {} {
162
global current_branch
163
161
- if {![can_merge]} return
164
+ if {![_can_merge]} return
165
166
set w .merge_setup
167
toplevel $w
@@ -171,10 +174,10 @@ proc do_local_merge {} {
174
175
frame $w.buttons
176
button $w.buttons.visualize -text Visualize \
174
- -command [list visualize_local_merge $w]
177
+ -command [namespace code [list _visualize $w]]
178
pack $w.buttons.visualize -side left
179
button $w.buttons.create -text Merge \
177
- -command [list start_local_merge_action $w]
180
+ -command [namespace code [list _start $w]]
181
pack $w.buttons.create -side right
182
button $w.buttons.cancel -text {Cancel} \
183
-command [list destroy $w]
@@ -226,7 +229,7 @@ proc do_local_merge {} {
229
tkwait window $w
230
}
231
229
-proc do_reset_hard {} {
232
+proc reset_hard {} {
233
global HEAD commit_type file_states
234
235
if {[string match amend* $commit_type]} {
@@ -252,14 +255,14 @@ Aborting the current $op will cause *ALL* uncommitted changes to be lost.
255
Continue with aborting the current $op?"] eq {yes}} {
256
set fd [open "| git read-tree --reset -u HEAD" r]
257
fconfigure $fd -blocking 0 -translation binary
255
- fileevent $fd readable [list reset_hard_wait $fd]
258
+ fileevent $fd readable [namespace code [list _reset_wait $fd]]
259
set ui_status_value {Aborting... please wait...}
260
} else {
261
unlock_index
262
}
263
}
264
262
-proc reset_hard_wait {fd} {
265
+proc _reset_wait {fd} {
266
global ui_comm
267
268
read $fd
@@ -279,3 +282,5 @@ proc reset_hard_wait {fd} {
282
rescan {set ui_status_value {Abort completed. Ready.}}
283
}
284
}
285
+
286
+}