[49846] trunk/base/src/registry1.0/receipt_flat.tcl

jmr at macports.org jmr at macports.org
Sat Apr 18 23:51:28 PDT 2009


Revision: 49846
          http://trac.macports.org/changeset/49846
Author:   jmr at macports.org
Date:     2009-04-18 23:51:27 -0700 (Sat, 18 Apr 2009)
Log Message:
-----------
only load any given receipt at most once

Modified Paths:
--------------
    trunk/base/src/registry1.0/receipt_flat.tcl

Modified: trunk/base/src/registry1.0/receipt_flat.tcl
===================================================================
--- trunk/base/src/registry1.0/receipt_flat.tcl	2009-04-19 05:07:47 UTC (rev 49845)
+++ trunk/base/src/registry1.0/receipt_flat.tcl	2009-04-19 06:51:27 UTC (rev 49846)
@@ -43,6 +43,8 @@
 
 # receipt_lastref is the last attributed index of receipts.
 variable receipt_lastref -1
+# maps port name,version,variants to the corresponding receipt ref
+variable ref_index
 
 ##
 #
@@ -101,6 +103,12 @@
 proc open_entry {name {version ""} {revision 0} {variants ""}} {
 	global macports::registry.installtype
 	global macports::registry.path
+	variable ref_index
+	
+	# if this entry is already open, just return the reference
+	if {[info exists ref_index($name,$version,$revision,$variants)]} {
+	    return $ref_index($name,$version,$revision,$variants)
+	}
 
 	set receipt_path [file join ${macports::registry.path} receipts ${name}]
 
@@ -195,6 +203,8 @@
 		}
 	}
 	
+	set ref_index($name,$version,$revision,$variants) $ref
+	
 	return $ref
 }
 
@@ -398,6 +408,15 @@
 # Delete an entry
 proc delete_entry {name version {revision 0} {variants ""}} {
 	global macports::registry.path
+	variable ref_index
+	
+	# if the entry is loaded, purge it
+	if {[info exists ref_index($name,$version,$revision,$variants)]} {
+	    set ref $ref_index($name,$version,$revision,$variants)
+	    variable receipt_${ref}
+	    array unset receipt_${ref}
+	    array unset ref_index "$name,$version,$revision,$variants"
+	}
 
 	set receipt_path [file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
 	if { [file exists ${receipt_path}] } {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090418/dba931d4/attachment.html>


More information about the macports-changes mailing list