<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/0133f0617001ef9ce6b412d16e9ca2dc932c08d3">https://github.com/macports/macports-base/commit/0133f0617001ef9ce6b412d16e9ca2dc932c08d3</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 0133f0617001ef9ce6b412d16e9ca2dc932c08d3
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Fri Feb 2 11:07:52 2024 +1100
<span style='display:block; white-space:pre;color:#404040;'> use dict in action_{select,selfupdate,deps}
</span>---
src/port/port.tcl | 115 +++++++++++++++++++++++-------------------------------
1 file changed, 48 insertions(+), 67 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port/port.tcl b/src/port/port.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 507f040cd..b284d6c1a 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2283,12 +2283,10 @@ proc action_deactivate { action portlist opts } {
</span> proc action_select { action portlist opts } {
ui_debug "action_select \[$portlist] \[$opts]..."
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set opts_array $opts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set commands [array names opts_array ports_select_*]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset opts_array
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set commands [dict keys $opts ports_select_*]
</span>
# Error out if no group is specified or command is not --summary.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[llength $portlist] < 1 && [string map {ports_select_ ""} [lindex $commands 0]] != "summary"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $portlist] < 1 && [string map {ports_select_ ""} [lindex $commands 0]] ne "summary"} {
</span> ui_error "Incorrect usage. Correct synopsis is one of:"
ui_msg " port select \[--list|--show\] <group>"
ui_msg " port select \[--set\] <group> <version>"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2401,8 +2399,7 @@ proc action_select { action portlist opts } {
</span>
set groups [list]
foreach pg $portgroups {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set groupdesc {}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set groupdesc(name) [string trim $pg]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set groupdesc [dict create name [string trim $pg]]
</span>
if {[catch {mportselect list $pg} versions]} {
ui_warn "The list of options for the select group $pg could not be obtained: $versions"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2412,28 +2409,25 @@ proc action_select { action portlist opts } {
</span> set noneidx [lsearch -exact $versions "none"]
set versions [lsort [lreplace $versions $noneidx $noneidx]]
lappend versions "none"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set groupdesc(versions) $versions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set groupdesc versions $versions
</span>
if {[catch {mportselect show $pg} selected_version]} {
ui_warn "The currently selected option for the select group $pg could not be obtained: $selected_version"
continue
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set groupdesc(selected) $selected_version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set groupdesc selected $selected_version
</span>
set w1 [expr {max($w1, [string length $pg])}]
set w2 [expr {max($w2, [string length $selected_version])}]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend groups [array get groupdesc]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset groupdesc
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend groups $groupdesc
</span> }
if {![macports::ui_isset ports_quiet]} {
puts [format $formatStr $w1 "Name" $w2 "Selected" "Options"]
puts [format $formatStr $w1 "====" $w2 "========" "======="]
}
foreach groupdesc $groups {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set groupd $groupdesc
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts [format $formatStr $w1 $groupd(name) $w2 $groupd(selected) [join $groupd(versions) " "]]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset groupd
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts [format $formatStr $w1 [dict get $groupd name] $w2 [dict get $groupd selected] [join [dict get $groupd versions] " "]]
</span> }
return 0
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2446,16 +2440,15 @@ proc action_select { action portlist opts } {
</span>
proc action_selfupdate { action portlist opts } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global global_options
</span> if {[prefix_unwritable]} {
return 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options [array get global_options]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists options(ports_${action}_nosync)] && $options(ports_${action}_nosync) eq "yes"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set options [array get ::global_options]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $options ports_${action}_nosync] && [dict get $options ports_${action}_nosync] eq "yes"} {
</span> ui_warn "port selfupdate --nosync is deprecated, use --no-sync instead"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set options(ports_${action}_no-sync) $options(ports_${action}_nosync)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set options ports_${action}_no-sync [dict get $options ports_${action}_nosync]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if { [catch {macports::selfupdate [array get options] base_updated} result ] } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if { [catch {macports::selfupdate $options base_updated} result ] } {
</span> ui_debug $::errorInfo
ui_error $result
if {![macports::ui_isset ports_verbose]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2697,12 +2690,12 @@ proc action_dependents { action portlist opts } {
</span>
proc action_deps { action portlist opts } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global global_variations
</span> set status 0
if {[require_portlist portlist]} {
return 1
}
set separator ""
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set labeldict [dict create depends_fetch Fetch depends_extract Extract depends_patch Patch depends_build Build depends_lib Library depends_run Runtime depends_test Test]
</span>
foreachport $portlist {
set deptypes [list]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2714,7 +2707,7 @@ proc action_deps { action portlist opts } {
</span> lappend deptypes depends_test
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo ""
</span> # If we have a url, use that, since it's most specific
# otherwise try to map the portname to a url
if {$porturl eq ""} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2726,8 +2719,8 @@ proc action_deps { action portlist opts } {
</span> if {[llength $result] < 2} {
break_softcontinue "Port $portname not found" 1 status
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [lindex $result 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set porturl $portinfo(porturl)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign $result portname portinfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set porturl [dict get $portinfo porturl]
</span> } elseif {$porturl ne "file://."} {
# Extract the portdir from porturl and use it to search PortIndex.
# Only the last two elements of the path (porturl) make up the
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2746,61 +2739,48 @@ proc action_deps { action portlist opts } {
</span> }
set matchindex [lsearch -exact -nocase $result $portname]
if {$matchindex != -1} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [lindex $result [incr matchindex]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign [lrange $result $matchindex ${matchindex}+1] portname portinfo
</span> } else {
ui_warn "Portdir $portdir doesn't seem to belong to portname $portname"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [lindex $result 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign $result portname portinfo
</span> }
}
if {!([dict exists $options ports_${action}_index] && [dict get $options ports_${action}_index] eq "yes")} {
# Add any global_variations to the variations
# specified for the port, so we get dependencies right
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset merged_variations
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array set merged_variations $variations
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach { variation value } [array get global_variations] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if { ![info exists merged_variations($variation)] } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set merged_variations($variation) $value
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set merged_variations [dict merge [array get ::global_variations] $variations]
</span> if {![dict exists $options subport]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists portinfo(name)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- dict set options subport $portinfo(name)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- dict set options subport $portname
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set options subport $portname
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {set mport [mportopen $porturl $options [array get merged_variations]]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set mport [mportopen $porturl $options $merged_variations]} result]} {
</span> ui_debug "$::errorInfo"
break_softcontinue "Unable to open port: $result" 1 status
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [mportinfo $mport]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo [dict merge $portinfo [mportinfo $mport]]
</span> mportclose $mport
<span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {![info exists portinfo]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {$portinfo eq ""} {
</span> ui_warn "port ${action} --index does not work with the 'current' pseudo-port"
continue
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portname $portinfo(name)
</span>
set deplist [list]
set deps_output [list]
set ndeps 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set labeldict [list depends_fetch Fetch depends_extract Extract depends_patch Patch depends_build Build depends_lib Library depends_run Runtime depends_test Test]
</span> # get list of direct deps
foreach type $deptypes {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists portinfo($type)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $portinfo $type]} {
</span> if {$action eq "rdeps" || [macports::ui_isset ports_verbose]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach dep $portinfo($type) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dep [dict get $portinfo $type] {
</span> lappend deplist $dep
}
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach dep $portinfo($type) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dep [dict get $portinfo $type] {
</span> lappend deplist [lindex [split $dep :] end]
}
}
if {$action eq "deps"} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set label "$labeldict($type) Dependencies"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set label "[dict get $labeldict $type] Dependencies"
</span> lappend deps_output [wraplabel $label [join $deplist ", "] 0 [string repeat " " 22]]
incr ndeps [llength $deplist]
set deplist [list]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2808,10 +2788,10 @@ proc action_deps { action portlist opts } {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set version $portinfo(version)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set revision $portinfo(revision)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists portinfo(canonical_active_variants)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set variants $portinfo(canonical_active_variants)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set version [dict get $portinfo version]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set revision [dict get $portinfo revision]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $portinfo canonical_active_variants]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variants [dict get $portinfo canonical_active_variants]
</span> } else {
set variants {}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2829,13 +2809,15 @@ proc action_deps { action portlist opts } {
</span> }
set toplist $deplist
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen [dict create]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set depsof [dict create]
</span> # gather all the deps
while 1 {
set newlist [list]
foreach dep $deplist {
set depname [lindex [split $dep :] end]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists seen($depname)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set seen($depname) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![dict exists $seen $depname]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set seen $depname 1
</span>
# look up the dep
if {[catch {mportlookup $depname} result]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2845,33 +2827,31 @@ proc action_deps { action portlist opts } {
</span> if {[llength $result] < 2} {
break_softcontinue "Port $depname not found" 1 status
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [lindex $result 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set porturl $portinfo(porturl)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- dict set options subport $portinfo(name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo [lindex $result 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set porturl [dict get $portinfo porturl]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set options subport [dict get $portinfo name]
</span>
# open the portfile if requested
if {!([dict exists $options ports_${action}_index] && [dict get $options ports_${action}_index] eq "yes")} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {set mport [mportopen $porturl $options [array get merged_variations]]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set mport [mportopen $porturl $options $merged_variations]} result]} {
</span> ui_debug "$::errorInfo"
break_softcontinue "Unable to open port: $result" 1 status
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [mportinfo $mport]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo [dict merge $portinfo [mportinfo $mport]]
</span> mportclose $mport
}
# get list of the dep's deps
set rdeplist [list]
foreach type $deptypes {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists portinfo($type)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach rdep $portinfo($type) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $portinfo $type]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach rdep [dict get $portinfo $type] {
</span> lappend rdeplist $rdep
lappend newlist $rdep
}
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set depsof($depname) $rdeplist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set depsof $depname $rdeplist
</span> }
}
if {[llength $newlist] > 0} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2882,12 +2862,13 @@ proc action_deps { action portlist opts } {
</span> }
set portstack [list $toplist]
set pos_stack [list 0]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset seen
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen [dict create]
</span> if {[llength $toplist] > 0} {
ui_notice "The following ports are dependencies of $portname @${version}_${revision}${variants}:"
} else {
ui_notice "$portname @${version}_${revision}${variants} has no dependencies."
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set rdeps_full [expr {[dict exists $options ports_${action}_full] && [string is true -strict [dict get $options ports_${action}_full]]}]
</span> while 1 {
set cur_portlist [lindex $portstack end]
set cur_pos [lindex $pos_stack end]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2903,17 +2884,17 @@ proc action_deps { action portlist opts } {
</span> set cur_port [lindex $cur_portlist $cur_pos]
set cur_portname [lindex [split $cur_port :] end]
set spaces [string repeat " " [expr {[llength $pos_stack] * 2}]]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists seen($cur_portname)] || ([dict exists $options ports_${action}_full] && [string is true -strict [dict get $options ports_${action}_full]])} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![dict exists $seen $cur_portname] || $rdeps_full} {
</span> if {[macports::ui_isset ports_verbose]} {
puts "${spaces}${cur_port}"
} else {
puts "${spaces}${cur_portname}"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set seen($cur_portname) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set seen $cur_portname 1
</span> incr cur_pos
set pos_stack [lreplace $pos_stack end end $cur_pos]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists depsof($cur_portname)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend portstack $depsof($cur_portname)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $depsof $cur_portname]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend portstack [dict get $depsof $cur_portname]
</span> lappend pos_stack 0
}
continue
</pre><pre style='margin:0'>
</pre>