For emerge --metadata runs, update _eclasses_ metadata to insert local eclass
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Nov 2008 07:06:27 +0000 (07:06 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Nov 2008 07:06:27 +0000 (07:06 -0000)
paths. (trunk r11990)

svn path=/main/branches/2.1.6/; revision=11991

pym/portage/cache/util.py
pym/portage/eclass_cache.py

index dafaed09452bbfa42f10eb1e0581286be3b45876..dc3881b19f5058ef1f5d383def1c6a3192951387 100644 (file)
@@ -3,6 +3,8 @@
 # License: GPL2
 # $Id$
 
+__all__ = ["mirror_cache", "non_quiet_mirroring", "quiet_mirroring"]
+
 from itertools import chain
 from portage.cache import cache_errors
 
@@ -65,25 +67,34 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
 
                if write_it:
                        try:
-                               inherited = entry.get("INHERITED", None)
+                               inherited = entry.get("INHERITED", "")
+                               eclasses = entry.get("_eclasses_")
                        except cache_errors.CacheError, ce:
                                noise.exception(x, ce)
                                del ce
                                continue
+
+                       if eclasses is not None:
+                               if not eclass_cache.is_eclass_data_valid(entry["_eclasses_"]):
+                                       noise.eclass_stale(x)
+                                       continue
+                               inherited = eclasses
+                       else:
+                               inherited = inherited.split()
+
                        if inherited:
-                               if src_cache.complete_eclass_entries:
-                                       if not "_eclasses_" in entry:
-                                               noise.corruption(x,"missing _eclasses_ field")
-                                               continue
-                                       if not eclass_cache.is_eclass_data_valid(entry["_eclasses_"]):
-                                               noise.eclass_stale(x)
-                                               continue
-                               else:
-                                       entry["_eclasses_"] = eclass_cache.get_eclass_data(entry["INHERITED"].split(), \
-                                               from_master_only=True)
-                                       if not entry["_eclasses_"]:
-                                               noise.eclass_stale(x)
-                                               continue
+                               if src_cache.complete_eclass_entries and eclasses is None:
+                                       noise.corruption(x, "missing _eclasses_ field")
+                                       continue
+
+                               # Even if _eclasses_ already exists, replace it with data from
+                               # eclass_cache, in order to insert local eclass paths.
+                               eclasses = eclass_cache.get_eclass_data(inherited,
+                                       from_master_only=True)
+                               if eclasses is None:
+                                       noise.eclass_stale(x)
+                                       continue
+                               entry["_eclasses_"] = eclasses
 
                        # by this time, if it reaches here, the eclass has been validated, and the entry has 
                        # been updated/translated (if needs be, for metadata/cache mainly)
index de20d307c27b1c2b34393e5ae6fe746f3d281b9d..93c956f8a3e410554aa151f7f5be592566d4bb27 100644 (file)
@@ -3,6 +3,8 @@
 # License: GPL2
 # $Id$
 
+__all__ = ["cache"]
+
 from portage.util import normalize_path, writemsg
 import errno, os, sys
 from portage.data import portage_gid
@@ -63,14 +65,22 @@ class cache(object):
                                except OSError:
                                        continue
                                ys=y[:-eclass_len]
-                               self.eclasses[ys] = (x, long(mtime))
-                               self._eclass_locations[ys] = x
                                if x == self._master_eclass_root:
                                        master_eclasses[ys] = mtime
-                               else:
-                                       master_mtime = master_eclasses.get(ys)
-                                       if master_mtime and master_mtime != mtime:
+                                       self.eclasses[ys] = (x, mtime)
+                                       self._eclass_locations[ys] = x
+                                       continue
+
+                               master_mtime = master_eclasses.get(ys)
+                               if master_mtime is not None:
+                                       if master_mtime == mtime:
+                                               # It appears to be identical to the master,
+                                               # so prefer the master entry.
+                                               continue
+                                       else:
                                                self._master_eclasses_overridden[ys] = x
+                               self.eclasses[ys] = (x, mtime)
+                               self._eclass_locations[ys] = x
 
        def is_eclass_data_valid(self, ec_dict):
                if not isinstance(ec_dict, dict):