From e445fcfd94100fcf83ad39454bfcdcb801a56721 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 10 Jun 2011 05:04:17 -0700 Subject: bintree: always populate pkgindex REPO header The previous code would only populate it when there was no existing index file. Now, the default will be populated even if the file exists already. If an existing pkgindex header already defines these keys, then they will appropriately override our defaults. --- pym/portage/dbapi/bintree.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'pym/portage/dbapi/bintree.py') diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index ffa296c29..756ea6711 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -270,9 +270,23 @@ class binarytree(object): "REQUIRED_USE" : "" } self._pkgindex_inherited_keys = ["CHOST", "repository"] + + # Populate the header with appropriate defaults. self._pkgindex_default_header_data = { - "repository":"" + "VERSION" : str(self._pkgindex_version), + "repository" : "", } + + # It is especially important to populate keys like + # "repository" that save space when entries can + # inherit them from the header. If an existing + # pkgindex header already defines these keys, then + # they will appropriately override our defaults. + main_repo = self.settings.repositories.mainRepo() + if main_repo is not None: + self._pkgindex_default_header_data["repository"] = \ + main_repo.name + self._pkgindex_translated_keys = ( ("DESCRIPTION" , "DESC"), ("repository" , "REPO"), @@ -284,7 +298,6 @@ class binarytree(object): self._pkgindex_hashes, self._pkgindex_default_pkg_data, self._pkgindex_inherited_keys, - self._pkgindex_default_header_data, chain(*self._pkgindex_translated_keys) )) @@ -1280,14 +1293,7 @@ class binarytree(object): mode='r', encoding=_encodings['repo.content'], errors='replace') except EnvironmentError: - # 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 + pass else: try: pkgindex.read(f) -- cgit v1.2.3-1-g7c22