<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/eb95a32e5d4b2881d3e6c8b3ef9a1b85d5164de0">https://github.com/macports/macports-base/commit/eb95a32e5d4b2881d3e6c8b3ef9a1b85d5164de0</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new eb95a32e5 migration: use dict for options and portinfo
</span>eb95a32e5 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit eb95a32e5d4b2881d3e6c8b3ef9a1b85d5164de0
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Wed May 22 20:30:52 2024 +1000
<span style='display:block; white-space:pre;color:#404040;'> migration: use dict for options and portinfo
</span>---
src/macports1.0/migrate.tcl | 16 +++++++---------
src/macports1.0/restore.tcl | 36 +++++++++++++++---------------------
src/macports1.0/snapshot.tcl | 25 +++++++++++--------------
3 files changed, 33 insertions(+), 44 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/migrate.tcl b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 5dfbce1b1..320458a1e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -44,7 +44,6 @@ namespace eval migrate {
</span> # caller should re-run itself and invoke migration with the --continue
# flag set.
proc main {opts} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options $opts
</span>
if {[needs_migration]} {
if {[info exists macports::ui_options(questions_yesno)]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -77,7 +76,7 @@ namespace eval migrate {
</span> # If port migrate was not called with --continue, the user probably did
# that manually and we do not have confirmation to run migration yet;
# do that now.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set continuation [expr {[info exists options(ports_migrate_continue)] && $options(ports_migrate_continue)}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set continuation [expr {[dict exists $opts ports_migrate_continue] && [dict get $opts ports_migrate_continue]}]
</span> if {!$continuation && [info exists macports::ui_options(questions_yesno)]} {
set msg "Migration will reinstall all installed ports."
set retvalue [$macports::ui_options(questions_yesno) $msg "MigrationContinuationPrompt" "" {y} 0 "Would you like to continue?"]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -142,10 +141,9 @@ namespace eval migrate {
</span> #
# @return 0 on success, an error on failure
proc restore_snapshot {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options {}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set options(ports_restore_last) yes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set options [dict create ports_restore_last yes]
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return [restore::main [array get options]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [restore::main $options]
</span> }
##
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -159,13 +157,13 @@ namespace eval migrate {
</span> # @return true on success, false if no update was performed, an error on
# failure.
proc upgrade_port_command {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set optionslist {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set options [dict create]
</span> # Force rebuild, but do not allow downgrade
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set optionslist(ports_selfupdate_migrate) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set options ports_selfupdate_migrate 1
</span> # Avoid portindex, which would trigger 'portindex', which does not work
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set optionslist(ports_selfupdate_nosync) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set options ports_selfupdate_nosync 1
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- selfupdate::main [array get optionslist] base_updated
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ selfupdate::main $options base_updated
</span> return $base_updated
}
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/restore.tcl b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 00ae50f40..27146c385 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -59,8 +59,6 @@ namespace eval restore {
</span> # Returns:
# 0 if success
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options $opts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> set restore::ui_prefix [string map {--- ===} $macports::ui_prefix]
if {[migrate::needs_migration]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -68,10 +66,10 @@ namespace eval restore {
</span> return 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists options(ports_restore_snapshot-id)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $opts ports_restore_snapshot-id]} {
</span> # use the specified snapshot
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set snapshot [fetch_snapshot $options(ports_restore_snapshot-id)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {[info exists options(ports_restore_last)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set snapshot [fetch_snapshot [dict get $opts ports_restore_snapshot-id]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {[dict exists $opts ports_restore_last]} {
</span> # use the last snapshot
set snapshot [fetch_snapshot_last]
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -374,12 +372,11 @@ namespace eval restore {
</span>
# Open the port with the requested variants from the snapshot
set variations [variants_to_variations_arr $variants]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {set mport [mportopen $portinfo(porturl) [list subport $portinfo(name)] $variations]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set mport [mportopen [dict get $portinfo porturl] [dict create subport [dict get $portinfo name]] $variations]} result]} {
</span> $progress intermission
error "Unable to open port '$portname': $result"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span>
# Compute the dependencies for the 'install' target. Do not recurse into the dependencies: we'll do that
# here manually in order to
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -401,9 +398,9 @@ namespace eval restore {
</span> lassign [dlist_search $macports::open_mports provides $dependency] dep_ditem
set conflict_found 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinfo [mportinfo $dep_ditem]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists portinfo(conflicts)] && [llength $portinfo(conflicts)] > 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach conflict $portinfo(conflicts) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinfo [mportinfo $dep_ditem]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $portinfo conflicts] && [llength [dict get $portinfo conflicts]] > 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach conflict [dict get $portinfo conflicts] {
</span> if {[info exists ports($conflict)]} {
# The conflicting port was installed in the snapshot. Assume that this happened because the
# conflicting port is an alternative provider for this dependency (e.g., curl-ca-bundle and
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -414,11 +411,11 @@ namespace eval restore {
</span> #
# Warn only once for every combination, otherwise users might see the same message multiple
# times.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists seen_conflicts($portinfo(name),$conflict)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set seen_conflicts($portinfo(name),$conflict) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists seen_conflicts([dict get $portinfo name],$conflict)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen_conflicts([dict get $portinfo name],$conflict) 1
</span>
$progress intermission
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn "Snapshot contains $conflict, which conflicts with dependency $portinfo(name); assuming $conflict provides the functionality of $portinfo(name)"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn "Snapshot contains $conflict, which conflicts with dependency [dict get $portinfo name]; assuming $conflict provides the functionality of [dict get $portinfo name]"
</span> $progress update $requested_counter $requested_total
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -434,7 +431,6 @@ namespace eval restore {
</span> }
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset portinfo
</span> if {$conflict_found} {
continue
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -556,15 +552,13 @@ namespace eval restore {
</span> _handle_failure failed $dependencies $name "port $name not found in the port index"
continue
}
<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 $res 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;'>+ set portinfo [lindex $res 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:#ffe0e0;'>- set options(ports_requested) $requested
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set options(subport) $portinfo(name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set options [dict create ports_requested $requested subport [dict get $portinfo name]]
</span> set variations [variants_to_variations_arr $variants]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {set workername [mportopen $porturl [array get options] $variations]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set workername [mportopen $porturl $options $variations]} result]} {
</span> ui_msg $::errorInfo
_handle_failure failed $dependencies $name "unable to open port $name: $result"
continue
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/snapshot.tcl b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 64452c0b1..bdfcc00b1 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -42,15 +42,13 @@ namespace eval snapshot {
</span> # Returns:
# registry::snapshot
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options $opts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists options(options_snapshot_order)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![dict exists $opts options_snapshot_order]} {
</span> set operation "create"
} else {
set operation ""
foreach op {list create diff delete} {
set opname "ports_snapshot_$op"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists options($opname)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $opts $opname]} {
</span> if {$operation ne ""} {
ui_error "Only one of the --list, --create, --diff, and --delete options can be specified."
error "Incorrect usage, see port snapshot --help."
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -61,7 +59,7 @@ namespace eval snapshot {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists options(ports_snapshot_help)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $opts ports_snapshot_help]} {
</span> ui_msg "Usage: One of:"
ui_msg " port snapshot \[--create\] \[--note '<message>'\]"
ui_msg " port snapshot --list"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -72,15 +70,15 @@ namespace eval snapshot {
</span>
switch $operation {
"create" {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return [create [array get options]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [create $opts]
</span> }
"list" {
ui_error "list operation not implemented"
}
"diff" {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set snapshot [registry::snapshot get_by_id $options(ports_snapshot_diff)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set snapshot [registry::snapshot get_by_id [dict get $opts ports_snapshot_diff]]
</span> array set diff [diff $snapshot]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set show_all [expr {[info exists options(ports_snapshot_all)]}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set show_all [dict exists $opts ports_snapshot_all]
</span> set note ""
if {!$show_all} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -146,13 +144,12 @@ namespace eval snapshot {
</span> }
proc create {opts} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set options $opts
</span>
registry::write {
# An option used by user while creating snapshot manually
# to identify a snapshot, usually followed by `port restore`
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists options(ports_snapshot_note)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set note $options(ports_snapshot_note)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $opts ports_snapshot_note]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set note [dict get $opts ports_snapshot_note]
</span> } else {
set note "snapshot created for migration"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -258,14 +255,14 @@ namespace eval snapshot {
</span> set added {}
set changed {}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set snapshot_ports {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set snapshot_ports [dict create]
</span>
foreach port $portlist {
lassign $port name requested active variants requested_variants
set active [expr {$active eq "installed"}]
set requested [expr {$requested == 1}]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set snapshot_ports($name) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set snapshot_ports $name 1
</span>
if {[catch {set installed [registry::installed $name]}]} {
# registry::installed failed, the port probably isn't installed
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -361,7 +358,7 @@ namespace eval snapshot {
</span> # port was installed on old OS, ignore
continue
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists snapshot_ports($iname)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $snapshot_ports $iname]} {
</span> # port was in the snapshot
continue
}
</pre><pre style='margin:0'>
</pre>