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
parent
3c1c2a00b2
commit
8329bd0725
|
@ -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 }
|
||||||
|
|
143
lib/remote.tcl
143
lib/remote.tcl
|
@ -132,91 +132,92 @@ 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
|
||||||
|
set enable 0
|
||||||
foreach r $all_remotes {
|
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
||||||
set enable 0
|
if {![catch {set a $repo_config(remote.$r.fetch)}]} {
|
||||||
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
set enable 1
|
||||||
if {![catch {set a $repo_config(remote.$r.fetch)}]} {
|
}
|
||||||
set enable 1
|
} else {
|
||||||
}
|
catch {
|
||||||
} else {
|
set fd [open [gitdir remotes $r] r]
|
||||||
catch {
|
while {[gets $fd n] >= 0} {
|
||||||
set fd [open [gitdir remotes $r] r]
|
if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
|
||||||
while {[gets $fd n] >= 0} {
|
set enable 1
|
||||||
if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
|
break
|
||||||
set enable 1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
close $fd
|
|
||||||
}
|
}
|
||||||
|
close $fd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$enable} {
|
||||||
|
if {![winfo exists $fetch_m]} {
|
||||||
|
menu $prune_m
|
||||||
|
$remote_m insert 0 cascade \
|
||||||
|
-label [mc "Prune from"] \
|
||||||
|
-menu $prune_m
|
||||||
|
|
||||||
|
menu $fetch_m
|
||||||
|
$remote_m insert 0 cascade \
|
||||||
|
-label [mc "Fetch from"] \
|
||||||
|
-menu $fetch_m
|
||||||
}
|
}
|
||||||
|
|
||||||
if {$enable} {
|
$fetch_m add command \
|
||||||
if {![winfo exists $fetch_m]} {
|
-label $r \
|
||||||
menu $prune_m
|
-command [list fetch_from $r]
|
||||||
$remote_m insert 0 cascade \
|
$prune_m add command \
|
||||||
-label [mc "Prune from"] \
|
-label $r \
|
||||||
-menu $prune_m
|
-command [list prune_from $r]
|
||||||
|
|
||||||
menu $fetch_m
|
|
||||||
$remote_m insert 0 cascade \
|
|
||||||
-label [mc "Fetch from"] \
|
|
||||||
-menu $fetch_m
|
|
||||||
}
|
|
||||||
|
|
||||||
$fetch_m add command \
|
|
||||||
-label $r \
|
|
||||||
-command [list fetch_from $r]
|
|
||||||
$prune_m add command \
|
|
||||||
-label $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
|
||||||
|
set enable 0
|
||||||
foreach r $all_remotes {
|
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
||||||
set enable 0
|
if {![catch {set a $repo_config(remote.$r.push)}]} {
|
||||||
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
set enable 1
|
||||||
if {![catch {set a $repo_config(remote.$r.push)}]} {
|
|
||||||
set enable 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
catch {
|
|
||||||
set fd [open [gitdir remotes $r] r]
|
|
||||||
while {[gets $fd n] >= 0} {
|
|
||||||
if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
|
|
||||||
set enable 1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close $fd
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if {$enable} {
|
catch {
|
||||||
if {![winfo exists $push_m]} {
|
set fd [open [gitdir remotes $r] r]
|
||||||
menu $push_m
|
while {[gets $fd n] >= 0} {
|
||||||
$remote_m insert 0 cascade \
|
if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
|
||||||
-label [mc "Push to"] \
|
set enable 1
|
||||||
-menu $push_m
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close $fd
|
||||||
$push_m add command \
|
|
||||||
-label $r \
|
|
||||||
-command [list push_to $r]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if {$enable} {
|
||||||
|
if {![winfo exists $push_m]} {
|
||||||
|
menu $push_m
|
||||||
|
$remote_m insert 0 cascade \
|
||||||
|
-label [mc "Push to"] \
|
||||||
|
-menu $push_m
|
||||||
|
}
|
||||||
|
|
||||||
|
$push_m add command \
|
||||||
|
-label $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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue