[45034] trunk/base/src
perry at macports.org
perry at macports.org
Tue Jan 6 17:47:45 PST 2009
Revision: 45034
http://trac.macports.org/changeset/45034
Author: perry at macports.org
Date: 2009-01-06 17:47:44 -0800 (Tue, 06 Jan 2009)
Log Message:
-----------
src/port, src/port1.0 - Cleaned up the variants code related to Ticket #14178.
* PortInfo(_variants) -> PortInfo(vinfo)
* `port variants --index` works now.
* action_variants uses PortInfo(variant_desc) as a fallback.
Modified Paths:
--------------
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2009-01-07 01:16:17 UTC (rev 45033)
+++ trunk/base/src/port/port.tcl 2009-01-07 01:47:44 UTC (rev 45034)
@@ -1568,11 +1568,12 @@
# ... special formatting for certain fields when prettyprinting
if {$pretty_print} {
if {$ropt eq "variants"} {
- # Only use the new key for variants if it exists in PortInfo.
- # Note that this key does not currently exist outside of trunk.
- array unset variants
- if {[info exists portinfo(_variants)]} {
- array set variants $portinfo(_variants)
+ # Use the new format for variants iff it exists in
+ # PortInfo. This key currently does not exist outside of
+ # trunk (1.8.0).
+ array unset vinfo
+ if {[info exists portinfo(vinfo)]} {
+ array set vinfo $portinfo(vinfo)
}
set pi_vars $inf
@@ -1586,11 +1587,11 @@
# selected by variants.conf, prefixed with (+)/(-)
set mod "($global_variations($v))"
# Retrieve additional information from the new key.
- } elseif {[info exists variants]} {
+ } elseif {[info exists vinfo]} {
array unset variant
- array set variant $variants($v)
- if {$variant(is_default) eq "+"} {
- set mod "\[+\]"
+ array set variant $vinfo($v)
+ if {[info exists variant(is_default)]} {
+ set mod "\[+]"
}
}
lappend inf "$mod$v"
@@ -2221,7 +2222,6 @@
}
array unset portinfo
- array unset variants
array set portinfo [lindex $result 1]
# set portname again since the one we were passed may not have had the correct case
set portname $portinfo(name)
@@ -2245,34 +2245,59 @@
}
# if this fails the port doesn't have any variants
- if { ! [ info exists portinfo(_variants) ] } {
+ if {![info exists portinfo(variants)]} {
puts "$portname has no variants"
} else {
- array set variants $portinfo(_variants)
+ array unset vinfo
+ # Use the new format if it exists.
+ if {[info exists portinfo(vinfo)]} {
+ array set vinfo $portinfo(vinfo)
+ # Otherwise fall back to the old format.
+ } else {
+ if {[info exists portinfo(variant_desc)]} {
+ array set vdescriptions $portinfo(variant_desc)
+ }
+ }
# print out all the variants
puts "$portname has the variants:"
- foreach vname [ lsort [ array names variants ] ] {
- array unset vinfo
- array set vinfo $variants($vname)
+ foreach v $portinfo(variants) {
+ set mod ""
+ unset -nocomplain vconflicts vdescription vrequires
+ # Retrieve variants' information from the new format.
+ if {[info exists vinfo]} {
+ array unset variant
+ array set variant $vinfo($v)
- if { [ info exists vinfo(is_default) ] \
- && $vinfo(is_default) == "+" } {
- set mod "\[+] "
- } else {
- set mod {}
+ # Retrieve conflicts, description, is_default, and
+ # vrequires.
+ if {[info exists variant(conflicts)]} {
+ set vconflicts $variant(conflicts)
+ }
+ if {[info exists variant(description)]} {
+ set vdescription $variant(description)
+ }
+ if {[info exists variant(is_default)]} {
+ set mod "\[+] "
+ }
+ if {[info exists variant(requires)]} {
+ set vrequires $variant(requires)
+ }
+ # Retrieve variants' information from the old format,
+ # which only consists of the description.
+ } elseif {[info exists vdescriptions($v)]} {
+ set vdescription $vdescriptions($v)
}
- puts -nonewline "\t$mod$vname"
- if { [ info exists vinfo(description) ] } {
- puts -nonewline ": [ string trim $vinfo(description) ]"
+
+ puts -nonewline "\t$mod$v"
+ if {[info exists vdescription]} {
+ puts -nonewline ": [string trim $vdescription]"
}
- if { [ info exists vinfo(conflicts) ] \
- && $vinfo(conflicts) != "" } {
- puts -nonewline "\n\t * conflicts with [ string trim $vinfo(conflicts) ]"
+ if {[info exists vconflicts]} {
+ puts -nonewline "\n\t * conflicts with [string trim $vconflicts]"
}
- if { [ info exists vinfo(requires) ] \
- && $vinfo(requires) != "" } {
- puts -nonewline "\n\t * requires [ string trim $vinfo(requires) ]"
+ if {[info exists vrequires]} {
+ puts -nonewline "\n\t * requires [string trim $vrequires]"
}
puts ""
}
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2009-01-07 01:16:17 UTC (rev 45033)
+++ trunk/base/src/port1.0/portutil.tcl 2009-01-07 01:47:44 UTC (rev 45034)
@@ -372,22 +372,18 @@
proc variant {args} {
global all_variants PortInfo porturl
- # Perhaps a little self-explanatory ;), but PortInfo(_variants) contains
- # the variants associated with a Portfile. Each key, the variant's name,
- # maps to an array, the variant, which contains the following keys:
+ # Each key in PortInfo(vinfo) maps to an array which contains the
+ # following keys:
# * conflicts
- # * description
- # * is_default
+ # * description: This key's mapping is duplicated in
+ # PortInfo(variant_desc) for backward compatibility
+ # reasons (specifically 1.7.0's format of PortIndex).
+ # * is_default: This key exists iff the variant is a default variant.
# * requires
- # XXX: PortInfo(_variants)'s contents *should* eventually replace
- # PortInfo(variants)'s contents. Once I've finished transitioning the
- # code to use the new format, I will rename PortInfo(_variants) as
- # PortInfo(variants) (and hopefully everything will continue to work).
- # -- perry
- if { ! [ info exists PortInfo(_variants) ] } {
- set PortInfo(_variants) {}
+ if {![info exists PortInfo(vinfo)]} {
+ set PortInfo(vinfo) {}
}
- array set variants $PortInfo(_variants)
+ array set vinfo $PortInfo(vinfo)
set len [llength $args]
set code [lindex $args end]
@@ -424,14 +420,16 @@
variant_remove_ditem $variant_provides
} else {
# Create an array to contain the variant's information.
- if { ! [ info exists variants($variant_provides) ] } {
- set variants($variant_provides) {}
+ if {![info exists vinfo($variant_provides)]} {
+ set vinfo($variant_provides) {}
}
- array set variant $variants($variant_provides)
+ array set variant $vinfo($variant_provides)
- # Set conflicts (if any).
- set vconflicts [ join [ lsort [ ditem_key $ditem conflicts ] ] ]
- array set variant [ list conflicts $vconflicts ]
+ # Set conflicts.
+ set vconflicts [join [lsort [ditem_key $ditem conflicts]]]
+ if {$vconflicts ne ""} {
+ array set variant [list conflicts $vconflicts]
+ }
lappend PortInfo(variants) $variant_provides
set vdesc [join [ditem_key $ditem description]]
@@ -441,24 +439,24 @@
set vdesc [variant_desc $porturl $variant_provides]
}
- # Set description (if any).
- if {$vdesc != ""} {
- array set variant [ list description $vdesc ]
+ # Set description.
+ if {$vdesc ne ""} {
+ array set variant [list description $vdesc]
+ # XXX: The following line should be removed after 1.8.0 is
+ # released.
+ lappend PortInfo(variant_desc) $variant_provides $vdesc
}
- # Set is_default.
- if { ! [ info exists variant(is_default) ] } {
- array set variant [ list is_default "-" ]
+ # Set requires.
+ set vrequires [join [lsort [ditem_key $ditem requires]]]
+ if {$vrequires ne ""} {
+ array set variant [list requires $vrequires]
}
-
- # Set requires (if any).
- set vrequires [ join [ lsort [ ditem_key $ditem requires ] ] ]
- array set variant [ list requires $vrequires ]
}
- # Add variant to PortInfo(_variants)
- array set variants [ list $variant_provides [ array get variant ] ]
- set PortInfo(_variants) [ array get variants ]
+ # Add the variant (back) to PortInfo(vinfo).
+ array set vinfo [list $variant_provides [array get variant]]
+ set PortInfo(vinfo) [array get vinfo]
# Finally append the ditem to the dlist.
lappend all_variants $ditem
@@ -1880,31 +1878,31 @@
global variations
switch -regex $action {
set|append {
- # Retrieve the variants associated with this Portfile.
- if { ! [ info exists PortInfo(_variants) ] } {
- set PortInfo(_variants) {}
+ # Retrieve the information associated with each variant.
+ if {![info exists PortInfo(vinfo)]} {
+ set PortInfo(vinfo) {}
}
- array set variants $PortInfo(_variants)
+ array set vinfo $PortInfo(vinfo)
foreach v $value {
if {[regexp {([-+])([-A-Za-z0-9_]+)} $v whole val variant]} {
# Retrieve the information associated with this variant.
- if { ! [ info exists variants($variant) ] } {
- set variants($variant) {}
+ if {![info exists vinfo($variant)]} {
+ set vinfo($variant) {}
}
- array set vinfo $variants($variant)
+ array set info $vinfo($variant)
if {![info exists variations($variant)]} {
- # Set is_default and update variants.
- array set vinfo [ list is_default "+" ]
- array set variants [ list $variant [ array get vinfo ] ]
+ # Set is_default and update vinfo.
+ array set info [list is_default val]
+ array set vinfo [list $variant [array get info]]
set variations($variant) $val
}
}
}
- # Update PortInfo(_variants).
- set PortInfo(_variants) [ array get variants ]
+ # Update PortInfo(vinfo).
+ set PortInfo(vinfo) [array get vinfo]
}
delete {
# xxx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090106/d714859e/attachment-0001.html>
More information about the macports-changes
mailing list