Remove paths from _eclasses_ serialization in the cache. This makes the mtimes of...
authorZac Medico <zmedico@gentoo.org>
Tue, 24 Oct 2006 07:20:12 +0000 (07:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Oct 2006 07:20:12 +0000 (07:20 -0000)
svn path=/main/trunk/; revision=4807

pym/cache/template.py
pym/eclass_cache.py

index ff2bbeacf4e4c6db66c8a98035b25ac7717e1bd0..547490e29443612501cbfe0a3759d9f245b1e93c 100644 (file)
@@ -157,7 +157,8 @@ class database(object):
 
 def serialize_eclasses(eclass_dict):
        """takes a dict, returns a string representing said dict"""
-       return "\t".join(["%s\t%s\t%s" % (k, v[0], str(v[1])) for k,v in eclass_dict.items()])
+       return "\t".join(["%s\t%s" % (k, str(v)) \
+               for k, v in eclass_dict.iteritems()])
 
 def reconstruct_eclasses(cpv, eclass_string):
        """returns a dict when handed a string generated by serialize_eclasses"""
@@ -165,10 +166,20 @@ def reconstruct_eclasses(cpv, eclass_string):
        if eclasses == [""]:
                # occasionally this occurs in the fs backends.  they suck.
                return {}
-       if len(eclasses) % 3 != 0:
+       
+       if len(eclasses) % 2 != 0 and len(eclasses) % 3 != 0:
                raise cache_errors.CacheCorruption(cpv, "_eclasses_ was of invalid len %i" % len(eclasses))
        d={}
-       for x in range(0, len(eclasses), 3):
-               d[eclasses[x]] = (eclasses[x + 1], long(eclasses[x + 2]))
+       has_paths = False
+       try:
+               long(eclasses[1])
+       except ValueError:
+               has_paths = True
+       if has_paths:
+               for x in range(0, len(eclasses), 3):
+                       d[eclasses[x]] = long(eclasses[x + 2])
+       else:
+               for x in range(0, len(eclasses), 2):
+                       d[eclasses[x]] = long(eclasses[x + 1])
        del eclasses
        return d
index 8d2a2bb813325121803b30e39869de95db0a6023..904e63261d21de39bb0b765175707a6826bfede1 100644 (file)
@@ -15,6 +15,7 @@ class cache:
                self.porttree_root = porttree_root
 
                self.eclasses = {} # {"Name": ("location","_mtime_")}
+               self._eclass_locations = {}
 
                # screw with the porttree ordering, w/out having bash inherit match it, and I'll hurt you.
                # ~harring
@@ -38,6 +39,7 @@ class cache:
 
        def update_eclasses(self):
                self.eclasses = {}
+               self._eclass_locations = {}
                eclass_len = len(".eclass")
                for x in [normalize_path(os.path.join(y,"eclass")) for y in self.porttrees]:
                        if not os.path.isdir(x):
@@ -48,13 +50,14 @@ class cache:
                                except OSError:
                                        continue
                                ys=y[:-eclass_len]
-                               self.eclasses[ys] = (x, long(mtime))
+                               self.eclasses[ys] = long(mtime)
+                               self._eclass_locations[ys] = x
        
        def is_eclass_data_valid(self, ec_dict):
                if not isinstance(ec_dict, dict):
                        return False
-               for eclass, tup in ec_dict.iteritems():
-                       if eclass not in self.eclasses or tuple(tup) != self.eclasses[eclass]:
+               for eclass, mtime in ec_dict.iteritems():
+                       if eclass not in self.eclasses or mtime != self.eclasses[eclass]:
                                return False
 
                return True
@@ -68,7 +71,8 @@ class cache:
                                print "ec=",ec_dict
                                print "inherits=",inherits
                                raise
-                       if from_master_only and self.eclasses[x][0] != self._master_eclass_root:
+                       if from_master_only and \
+                               self._eclass_locations[x] != self._master_eclass_root:
                                return None
 
                return ec_dict