RepoConfig.update(): copy more attributes
authorZac Medico <zmedico@gentoo.org>
Wed, 28 Dec 2011 07:13:41 +0000 (23:13 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 28 Dec 2011 07:13:41 +0000 (23:13 -0800)
This fixes a regression since commit
10246cd535f909dda8bd05de617c32d2b8a56b4a which caused layout.conf
settings such as thin-manifests to be ignored for repositories that
had repos.conf settings that did not specify the repository location.
In order to trigger this case, ResolverPlayground has been modified to
omit the location of each repository in the repos.conf file that it
generates.

pym/portage/repository/config.py
pym/portage/tests/ebuild/test_config.py
pym/portage/tests/resolver/ResolverPlayground.py

index f98b9b7eacbfd0614a55f1787e685288dabfae1d..4bf995e33e3f5df769e69c1f9587470daa937769 100644 (file)
@@ -199,8 +199,9 @@ class RepoConfig(object):
        def update(self, new_repo):
                """Update repository with options in another RepoConfig"""
 
-               for k in ('aliases', 'eclass_overrides', 'location', 'masters',
-                       'name', 'priority', 'sync', 'user_location'):
+               keys = set(self.__slots__)
+               keys.discard("missing_repo_name")
+               for k in keys:
                        v = getattr(new_repo, k, None)
                        if v is not None:
                                setattr(self, k, v)
@@ -324,7 +325,13 @@ class RepoConfigLoader(object):
                                        repo_opts = default_repo_opts.copy()
                                        repo_opts['location'] = ov
                                        repo = RepoConfig(None, repo_opts)
-                                       # repos_conf_opts contains options from /etc/portage/repos.conf
+                                       # repos_conf_opts may contain options from various places:
+                                       # 1) /etc/portage/repos.conf
+                                       # 2) $location/metadata/layout.conf if repos.conf specified
+                                       #    the repo location
+                                       # 3) A RepoConfig instance corresponding to a previously
+                                       #    processed path in the current list of overlays which
+                                       #    referred to a repository with the same name.
                                        repos_conf_opts = prepos.get(repo.name)
                                        if repos_conf_opts is not None:
                                                if repos_conf_opts.aliases is not None:
index 570cb2bc94d8eb56912543c8fe52cc608c54515c..35694ede74b04c2e51d3c38aaf5d6de04feff9ac 100644 (file)
@@ -243,6 +243,8 @@ class ConfigTestCase(TestCase):
                self.assertTrue(len(new_repo_config.masters) > 0, "new_repo has no default master")
                self.assertEqual(new_repo_config.masters[0].user_location, playground.portdir,
                        "new_repo default master is not PORTDIR")
+               self.assertEqual(new_repo_config.thin_manifest, True,
+                       "new_repo_config.thin_manifest != True")
 
                new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "A", "Manifest")
                self.assertEqual(os.path.exists(new_manifest_file), False)
index 201c5c4af49c3d769dfdbd78d8039ae28f5baa0f..140b25d6e4f66f3057e7e3c1906fcd47afa196a7 100644 (file)
@@ -376,17 +376,13 @@ class ResolverPlayground(object):
                                with open(os.path.join(metadata_dir, "metadata.xml"), 'w') as f:
                                        f.write(herds_xml)
 
+               # Write empty entries for each repository, in order to exercise
+               # RepoConfigLoader's repos.conf processing.
                repos_conf_file = os.path.join(user_config_dir, "repos.conf")           
                f = open(repos_conf_file, "w")
-               priority = 0
                for repo in sorted(self.repo_dirs.keys()):
                        f.write("[%s]\n" % repo)
-                       f.write("LOCATION=%s\n" % self.repo_dirs[repo])
-                       if repo == "test_repo":
-                               f.write("PRIORITY=%s\n" % -1000)
-                       else:
-                               f.write("PRIORITY=%s\n" % priority)
-                               priority += 1
+                       f.write("\n")
                f.close()
 
                for config_file, lines in user_config.items():