<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch release-2.9
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/9a1b3b053554b50921af430a9a01d90023e01bfc">https://github.com/macports/macports-base/commit/9a1b3b053554b50921af430a9a01d90023e01bfc</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/release-2.9 by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 9a1b3b053 dlist_match_multi: support better comparison
</span>9a1b3b053 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 9a1b3b053554b50921af430a9a01d90023e01bfc
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sun Feb 18 21:45:06 2024 +1100
<span style='display:block; white-space:pre;color:#404040;'> dlist_match_multi: support better comparison
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The options and variations for an mport are lists of key/value pairs
</span><span style='display:block; white-space:pre;color:#404040;'> with no guaranteed order. To compare them correctly requires a function
</span><span style='display:block; white-space:pre;color:#404040;'> more sophisticated than a simple string comparison.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Adding a new arg to dlist_match_multi to allowing specifying a
</span><span style='display:block; white-space:pre;color:#404040;'> comparison function to use for any of the keys, and a new proc
</span><span style='display:block; white-space:pre;color:#404040;'> called dictequal to use with it in mportopen and mportdepends.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> (cherry picked from commit d2592abd50eddd25347ecf2b92e9a6445be6a661)
</span>---
src/macports1.0/macports.tcl | 6 ++++--
src/macports1.0/macports_dlist.tcl | 12 ++++++++++--
src/macports1.0/macports_util.tcl | 15 +++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 9b64f035d..2e5664f87 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2039,7 +2039,8 @@ proc mportopen {porturl {options {}} {variations {}} {nocache {}}} {
</span> if {$nocache ne ""} {
set mport ""
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set mport [dlist_match_multi $macports::open_mports [list porturl $porturl variations $variations options $options]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set comparators [dict create variations dictequal options dictequal]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set mport [dlist_match_multi $macports::open_mports [list porturl $porturl variations $variations options $options] $comparators]
</span> }
if {$mport ne ""} {
# just in case more than one somehow matches
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3771,7 +3772,8 @@ proc mportdepends {mport {target {}} {recurseDeps 1} {skipSatisfied 1} {accDeps
</span> # we potentially leak mport references if we mportopen each time,
# because mportexec only closes each open mport once.
set matchlistname [expr {$depListName ne {} ? "depList" : "macports::open_mports"}]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set depport_matches [dlist_match_multi [set $matchlistname] [list porturl $dep_portinfo(porturl) options $dep_options]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set comparators [dict create options dictequal]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set depport_matches [dlist_match_multi [set $matchlistname] [list porturl $dep_portinfo(porturl) options $dep_options] $comparators]
</span> # if multiple matches, the most recently opened one is more likely what we want
set depport [lindex $depport_matches end]
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports_dlist.tcl b/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 7201532c9..adf8752ba 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -56,13 +56,21 @@ package provide macports_dlist 1.0
</span> # Returns all dependency entries for which the entry's value for 'key' exactly matches the given 'value'.
# dlist - the dependency list to search
# criteria - the key/value pairs to compare
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# cmp - dict mapping keys to a procedure name to compare them
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# should return 0 if equal, nonzero otherwise
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# (simple string comparison is used for keys not in the dict)
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc dlist_match_multi {dlist criteria} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc dlist_match_multi {dlist criteria {cmp {}}} {
</span> set result [list]
foreach ditem $dlist {
set match 1
foreach {key value} $criteria {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[ditem_key $ditem $key] ne $value} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $cmp $key]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[[dict get $cmp $key] [ditem_key $ditem $key] $value] != 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set match 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {[ditem_key $ditem $key] ne $value} {
</span> set match 0
break
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports_util.tcl b/src/macports1.0/macports_util.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 179b15e74..b74473358 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports_util.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports_util.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -186,6 +186,21 @@ proc lunshift {varName args} {
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# dictequal dictA dictB
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Returns 0 if the two given dicts have exactly the same keys and map
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# them to exactly the same values. Returns 1 otherwise.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc dictequal {a b} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict size $a] != [dict size $b]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict for {key val} $a {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![dict exists $b $key] || $val ne [dict get $b $key]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # bytesize filesize ?unit? ?format?
# Format an integer representing bytes using given units
proc bytesize {siz {unit {}} {format {%.2f}}} {
</pre><pre style='margin:0'>
</pre>