git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu

The meat of the routines is now separated to add_fetch_entry() and
add_push_entry(). This refactoring will allow easy implementation of adding
individual remotes later.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
maint
Petr Baudis 2008-09-24 22:44:00 +02:00 committed by Shawn O. Pearce
parent 3c1c2a00b2
commit 8329bd0725
2 changed files with 73 additions and 73 deletions

View File

@ -3263,8 +3263,7 @@ if {[is_enabled transport]} {
load_all_remotes load_all_remotes


set n [.mbar.remote index end] set n [.mbar.remote index end]
populate_push_menu populate_remotes_menu
populate_fetch_menu
set n [expr {[.mbar.remote index end] - $n}] set n [expr {[.mbar.remote index end] - $n}]
if {$n > 0} { if {$n > 0} {
if {[.mbar.remote type 0] eq "tearoff"} { incr n } if {[.mbar.remote type 0] eq "tearoff"} { incr n }

View File

@ -132,14 +132,11 @@ proc load_all_remotes {} {
set all_remotes [lsort -unique $all_remotes] set all_remotes [lsort -unique $all_remotes]
} }


proc populate_fetch_menu {} { proc add_fetch_entry {r} {
global all_remotes repo_config global repo_config

set remote_m .mbar.remote set remote_m .mbar.remote
set fetch_m $remote_m.fetch set fetch_m $remote_m.fetch
set prune_m $remote_m.prune set prune_m $remote_m.prune

foreach r $all_remotes {
set enable 0 set enable 0
if {![catch {set a $repo_config(remote.$r.url)}]} { if {![catch {set a $repo_config(remote.$r.url)}]} {
if {![catch {set a $repo_config(remote.$r.fetch)}]} { if {![catch {set a $repo_config(remote.$r.fetch)}]} {
@ -178,16 +175,12 @@ proc populate_fetch_menu {} {
-label $r \ -label $r \
-command [list prune_from $r] -command [list prune_from $r]
} }
}
} }


proc populate_push_menu {} { proc add_push_entry {r} {
global all_remotes repo_config global repo_config

set remote_m .mbar.remote set remote_m .mbar.remote
set push_m $remote_m.push set push_m $remote_m.push

foreach r $all_remotes {
set enable 0 set enable 0
if {![catch {set a $repo_config(remote.$r.url)}]} { if {![catch {set a $repo_config(remote.$r.url)}]} {
if {![catch {set a $repo_config(remote.$r.push)}]} { if {![catch {set a $repo_config(remote.$r.push)}]} {
@ -218,5 +211,13 @@ proc populate_push_menu {} {
-label $r \ -label $r \
-command [list push_to $r] -command [list push_to $r]
} }
}

proc populate_remotes_menu {} {
global all_remotes

foreach r $all_remotes {
add_fetch_entry $r
add_push_entry $r
} }
} }