Make flat_hash write keys in alphabetical order.
authorZac Medico <zmedico@gentoo.org>
Fri, 26 Sep 2008 01:15:44 +0000 (01:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 26 Sep 2008 01:15:44 +0000 (01:15 -0000)
svn path=/main/trunk/; revision=11552

pym/portage/cache/flat_hash.py
pym/portage/dbapi/porttree.py

index 40ad51eb6baafcb9654f64b66830d3728e24b847..219a4a22dea3644f9ef41d64646e578d7fa869e3 100644 (file)
@@ -16,7 +16,9 @@ class database(fs_template.FsBased):
                super(database,self).__init__(*args, **config)
                self.location = os.path.join(self.location, 
                        self.label.lstrip(os.path.sep).rstrip(os.path.sep))
-
+               write_keys = set(self._known_keys)
+               write_keys.add("_eclasses_")
+               self._write_keys = sorted(write_keys)
                if not self.readonly and not os.path.exists(self.location):
                        self._ensure_dirs()
 
@@ -73,13 +75,14 @@ class database(fs_template.FsBased):
                        else:
                                raise cache_errors.CacheCorruption(cpv, e)
 
-               for k, v in values.iteritems():
-                       if not v:
-                               continue
-                       if k != "_mtime_" and (k == "_eclasses_" or k in self._known_keys):
+               try:
+                       for k in self._write_keys:
+                               v = values.get(k)
+                               if not v:
+                                       continue
                                myf.write("%s=%s\n" % (k, v))
-
-               myf.close()
+               finally:
+                       myf.close()
                self._ensure_access(fp, mtime=values["_mtime_"])
 
                #update written.  now we move it.
index 33c8b52f293f96296c044bec55e3eb2390f0890d..2cc79b84991d00b2555ed50008da98877716fc80 100644 (file)
@@ -172,6 +172,7 @@ class portdbapi(dbapi):
                # XXX: REMOVE THIS ONCE UNUSED_0 IS YANKED FROM auxdbkeys
                # ~harring
                filtered_auxdbkeys = filter(lambda x: not x.startswith("UNUSED_0"), auxdbkeys)
+               filtered_auxdbkeys.sort()
                if secpass < 1:
                        from portage.cache import metadata_overlay, volatile
                        for x in self.porttrees: