Print error when section name set in repos.conf differs from name set inside repository.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Mon, 24 Jun 2013 17:04:14 +0000 (19:04 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Mon, 24 Jun 2013 17:04:14 +0000 (19:04 +0200)
pym/portage/repository/config.py

index 49af5e81d3822f8e66d1b315df42fc709a0d0804..13de814d5de0d6a138f29bf47073f5884b47d906 100644 (file)
@@ -153,14 +153,14 @@ class RepoConfig(object):
 
                eapi = None
                missing = True
+               self.name = name
                if self.location is not None:
                        eapi = read_corresponding_eapi_file(os.path.join(self.location, REPO_NAME_LOC))
-                       name, missing = self._read_valid_repo_name(self.location)
+                       self.name, missing = self._read_valid_repo_name(self.location)
                elif name == "DEFAULT": 
                        missing = False
 
                self.eapi = eapi
-               self.name = name
                self.missing_repo_name = missing
                # sign_commit is disabled by default, since it requires Git >=1.7.9,
                # and key_id configured by `git config user.signingkey key_id`
@@ -217,6 +217,10 @@ class RepoConfig(object):
                        self._eapis_banned = frozenset(layout_data['eapis-banned'])
                        self._eapis_deprecated = frozenset(layout_data['eapis-deprecated'])
 
+               if name is not None and name != self.name:
+                       raise ValueError(_("Section name '%s' set in repos.conf differs from name '%s' set inside repository") %
+                               (name, self.name))
+
        def eapi_is_banned(self, eapi):
                return eapi in self._eapis_banned
 
@@ -500,7 +504,11 @@ class RepoConfigLoader(object):
                        for oname in parser.options(sname):
                                optdict[oname] = parser.get(sname, oname)
 
-                       repo = RepoConfig(sname, optdict, local_config=local_config)
+                       try:
+                               repo = RepoConfig(sname, optdict, local_config=local_config)
+                       except ValueError as e:
+                               writemsg_level("!!! %s\n" % (e,), level=logging.ERROR, noiselevel=-1)
+                               continue
                        if repo.location and not exists_raise_eaccess(repo.location):
                                writemsg(_("!!! Invalid repos.conf entry '%s'"
                                        " (not a dir): '%s'\n") % (sname, repo.location), noiselevel=-1)