Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/emaint/modules/sync/
Date: Tue, 28 Feb 2017 18:43:36
Message-Id: 1488307318.9d14e63a814cab949ac49eb4d780b5545954da57.zmedico@gentoo
1 commit: 9d14e63a814cab949ac49eb4d780b5545954da57
2 Author: Alexandru Elisei <alexandru.elisei <AT> gmail <DOT> com>
3 AuthorDate: Mon Feb 27 14:15:44 2017 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue Feb 28 18:41:58 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9d14e63a
7
8 sync.py: recognize repo aliases when updating repositories (bug 610852)
9
10 Also when doing emerge --sync and using multiple repo names or aliases
11 duplicates are discarded.
12
13 X-Gentoo-Bug: 610852
14 X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=610852
15
16 pym/portage/emaint/modules/sync/sync.py | 28 ++++++++++++++++++++--------
17 1 file changed, 20 insertions(+), 8 deletions(-)
18
19 diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
20 index 9e3ca069e..ebdc362e1 100644
21 --- a/pym/portage/emaint/modules/sync/sync.py
22 +++ b/pym/portage/emaint/modules/sync/sync.py
23 @@ -137,9 +137,9 @@ class SyncRepos(object):
24
25 @staticmethod
26 def _match_repos(repos, available):
27 - '''Internal search, matches up the repo.name in repos
28 + '''Internal search, matches up the repo name or alias in repos.
29
30 - @param repos: list, of repo names to match
31 + @param repos: list of repo names or aliases to match
32 @param avalable: list of repo objects to search
33 @return: list of repo objects that match
34 '''
35 @@ -147,6 +147,9 @@ class SyncRepos(object):
36 for repo in available:
37 if repo.name in repos:
38 selected.append(repo)
39 + elif (repo.aliases is not None and
40 + any(alias in repos for alias in repo.aliases)):
41 + selected.append(repo)
42 return selected
43
44
45 @@ -154,14 +157,23 @@ class SyncRepos(object):
46 msgs = []
47 repos = self.emerge_config.target_config.settings.repositories
48 if match_repos is not None:
49 + # Discard duplicate repository names or aliases.
50 + match_repos = set(match_repos)
51 repos = self._match_repos(match_repos, repos)
52 if len(repos) < len(match_repos):
53 - available = [repo.name for repo in repos]
54 - missing = [repo for repo in match_repos if repo not in available]
55 - msgs.append(red(" * ") + "The specified repo(s) were not found: %s" %
56 - (" ".join(repo for repo in missing)) + \
57 - "\n ...returning")
58 - return (False, repos, msgs)
59 + # Build a set of all the matched repos' names and aliases so we
60 + # can do a set difference for names that are missing.
61 + repo_names = set()
62 + for repo in repos:
63 + repo_names.add(repo.name)
64 + if repo.aliases is not None:
65 + repo_names.update(repo.aliases)
66 + missing = match_repos - repo_names
67 + if missing:
68 + msgs.append(red(" * ") + "The specified repo(s) were not found: %s" %
69 + (" ".join(repo_name for repo_name in missing)) + \
70 + "\n ...returning")
71 + return (False, repos, msgs)
72
73 if auto_sync_only:
74 repos = self._filter_auto(repos)