commit: 9d14e63a814cab949ac49eb4d780b5545954da57 Author: Alexandru Elisei <alexandru.elisei <AT> gmail <DOT> com> AuthorDate: Mon Feb 27 14:15:44 2017 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Tue Feb 28 18:41:58 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9d14e63a
sync.py: recognize repo aliases when updating repositories (bug 610852) Also when doing emerge --sync and using multiple repo names or aliases duplicates are discarded. X-Gentoo-Bug: 610852 X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=610852 pym/portage/emaint/modules/sync/sync.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py index 9e3ca069e..ebdc362e1 100644 --- a/pym/portage/emaint/modules/sync/sync.py +++ b/pym/portage/emaint/modules/sync/sync.py @@ -137,9 +137,9 @@ class SyncRepos(object): @staticmethod def _match_repos(repos, available): - '''Internal search, matches up the repo.name in repos + '''Internal search, matches up the repo name or alias in repos. - @param repos: list, of repo names to match + @param repos: list of repo names or aliases to match @param avalable: list of repo objects to search @return: list of repo objects that match ''' @@ -147,6 +147,9 @@ class SyncRepos(object): for repo in available: if repo.name in repos: selected.append(repo) + elif (repo.aliases is not None and + any(alias in repos for alias in repo.aliases)): + selected.append(repo) return selected @@ -154,14 +157,23 @@ class SyncRepos(object): msgs = [] repos = self.emerge_config.target_config.settings.repositories if match_repos is not None: + # Discard duplicate repository names or aliases. + match_repos = set(match_repos) repos = self._match_repos(match_repos, repos) if len(repos) < len(match_repos): - available = [repo.name for repo in repos] - missing = [repo for repo in match_repos if repo not in available] - msgs.append(red(" * ") + "The specified repo(s) were not found: %s" % - (" ".join(repo for repo in missing)) + \ - "\n ...returning") - return (False, repos, msgs) + # Build a set of all the matched repos' names and aliases so we + # can do a set difference for names that are missing. + repo_names = set() + for repo in repos: + repo_names.add(repo.name) + if repo.aliases is not None: + repo_names.update(repo.aliases) + missing = match_repos - repo_names + if missing: + msgs.append(red(" * ") + "The specified repo(s) were not found: %s" % + (" ".join(repo_name for repo_name in missing)) + \ + "\n ...returning") + return (False, repos, msgs) if auto_sync_only: repos = self._filter_auto(repos)
