[88185] trunk/base/src/port/port.tcl
jberry at macports.org
jberry at macports.org
Wed Dec 21 11:04:00 PST 2011
Revision: 88185
http://trac.macports.org/changeset/88185
Author: jberry at macports.org
Date: 2011-12-21 11:03:58 -0800 (Wed, 21 Dec 2011)
Log Message:
-----------
When forming a portlist from search results against the repos,
return only unique items.
Modified Paths:
--------------
trunk/base/src/port/port.tcl
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2011-12-21 18:55:18 UTC (rev 88184)
+++ trunk/base/src/port/port.tcl 2011-12-21 19:03:58 UTC (rev 88185)
@@ -334,11 +334,10 @@
}
-proc add_to_portlist {listname portentry} {
- upvar $listname portlist
+proc entry_for_portlist {portentry} {
global global_options global_variations
- # The portlist currently has the following elements in it:
+ # Each portlist entry currently has the following elements in it:
# url if any
# name
# version (version_revision)
@@ -366,15 +365,21 @@
}
}
-
# Form the fully discriminated portname: portname/version_revison+-variants
set port(fullname) "$port(name)/[composite_version $port(version) $port(variants)]"
- # Add it to our portlist
- lappend portlist [array get port]
+ return [array get port]
}
+proc add_to_portlist {listname portentry} {
+ upvar $listname portlist
+
+ # Form portlist entry and add to portlist
+ lappend portlist [entry_for_portlist $portentry]
+}
+
+
proc add_ports_to_portlist {listname ports {overridelist ""}} {
upvar $listname portlist
@@ -686,30 +691,31 @@
##########################################
# Port selection
##########################################
+proc unique_results_to_portlist {infos} {
+ set result {}
+ array unset unique
+ foreach {name info} $infos {
+ array unset portinfo
+ array set portinfo $info
+
+ array unset entry
+ array set entry [entry_for_portlist [list url $portinfo(porturl) name $name]]
+ if {[info exists unique($entry(fullname))]} continue
+ set unique($entry(fullname)) 1
+ lappend result [array get entry]
+ }
+ return $result
+}
+
+
proc get_matching_ports {pattern {casesensitive no} {matchstyle glob} {field name}} {
if {[catch {set res [mportsearch $pattern $casesensitive $matchstyle $field]} result]} {
global errorInfo
ui_debug "$errorInfo"
fatal "search for portname $pattern failed: $result"
}
-
- set results {}
- foreach {name info} $res {
- array unset portinfo
- array set portinfo $info
-
- #set variants {}
- #if {[info exists portinfo(variants)]} {
- # foreach variant $portinfo(variants) {
- # lappend variants $variant "+"
- # }
- #}
- # For now, don't include version or variants with all ports list
- #"$portinfo(version)_$portinfo(revision)"
- #$variants
- add_to_portlist results [list url $portinfo(porturl) name $name]
- }
-
+ set results [unique_results_to_portlist $res]
+
# Return the list of all ports, sorted
return [portlist_sort $results]
}
@@ -724,13 +730,7 @@
ui_debug "$errorInfo"
fatal "listing all ports failed: $result"
}
- set results {}
- foreach {name info} $res {
- array unset portinfo
- array set portinfo $info
- add_to_portlist results [list url $portinfo(porturl) name $name]
- }
-
+ set results [unique_results_to_portlist $res]
set all_ports_cache [portlist_sort $results]
}
return $all_ports_cache
@@ -1168,7 +1168,7 @@
set reslist [opUnion $reslist $blist]
}
}
-
+
return $result
}
@@ -1437,7 +1437,7 @@
}
-proc uniqueEntries { entries } {
+proc unique_entries { entries } {
# Form the list of all the unique elements in the list a,
# considering only the port fullname, and taking the first
# found element first
@@ -1455,7 +1455,7 @@
proc opUnion { a b } {
# Return the unique elements in the combined two lists
- return uniqueEntries [concat $a $b]
+ return [unique_entries [concat $a $b]]
}
@@ -1476,14 +1476,14 @@
# First create a list of the fully discriminated names in b
array unset bfull
set i 0
- foreach bitem [uniqueEntries $b] {
+ foreach bitem [unique_entries $b] {
array set port $bitem
set bfull($port(fullname)) $i
incr i
}
# Walk through each item in a, matching against b
- foreach aitem [uniqueEntries $a] {
+ foreach aitem [unique_entries $a] {
array set port $aitem
# Quote the fullname and portname to avoid special characters messing up the regexp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20111221/1040efd8/attachment.html>
More information about the macports-changes
mailing list