bintree: populate REPO header for empty pkgindex v2.2.0_alpha38
authorZac Medico <zmedico@gentoo.org>
Mon, 6 Jun 2011 11:51:54 +0000 (04:51 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 6 Jun 2011 11:51:54 +0000 (04:51 -0700)
pym/portage/dbapi/bintree.py

index 33cd6580c7c7cb49c994f8f3a3661bb9d51fc6bf..ffa296c29723342debd77d012708ee2ee51a887e 100644 (file)
@@ -1280,7 +1280,14 @@ class binarytree(object):
                                mode='r', encoding=_encodings['repo.content'],
                                errors='replace')
                except EnvironmentError:
-                       pass
+                       # We're creating a new file, so populate the header
+                       # with appropriate defaults. This is especially
+                       # important for keys like REPO that save space when
+                       # entries can inherit them from the header.
+                       pkgindex.header["VERSION"] = str(self._pkgindex_version)
+                       main_repo = self.settings.repositories.mainRepo()
+                       if main_repo is not None:
+                               pkgindex.header["REPO"] = main_repo.name
                else:
                        try:
                                pkgindex.read(f)