commit:     ea04a583fab9739dbe05e8d8381ed2803e7dce88
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  9 13:07:58 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Wed Jul 10 16:55:20 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ea04a583

config: Allow a repository to be configured using one of its aliases

Currently, the `[name]` in repos.conf can only match the primary name.
This is inconvenient if a repository wants to change its name without
breaking existing configurations.

This raises the question of whether to then use the primary name or the
alias in the UI and in the vardb. I went with the primary name because
this is presumably the name that the repository actually wants you to
use.

If the configured name matches neither the primary name nor an alias,
then emaint sync will simply claim that it is not found, but that
behaviour is unchanged from before.

Bug: https://bugs.gentoo.org/935830
Closes: https://github.com/gentoo/portage/pull/1358
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 NEWS                             |  3 +++
 lib/portage/repository/config.py | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index d5a03533d9..53ba9f5fb1 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,9 @@ Bug fixes:
 
 * vartree, movefile: Warn when rewriting a symlink (bug #934514).
 
+* repository: config: Allow a repository to be configured using one of its
+  aliases rather than its primary name (bug #935830).
+
 portage-3.0.65 (2024-06-04)
 --------------
 

diff --git a/lib/portage/repository/config.py b/lib/portage/repository/config.py
index c9dfffa22c..46a2d83856 100644
--- a/lib/portage/repository/config.py
+++ b/lib/portage/repository/config.py
@@ -943,7 +943,9 @@ class RepoConfigLoader:
                         del prepos[repo_name]
                         continue
 
-                    if repo.name != repo_name:
+                    if repo.name != repo_name and (
+                        repo.aliases is None or repo_name not in repo.aliases
+                    ):
                         writemsg_level(
                             "!!! %s\n"
                             % _(
@@ -957,13 +959,13 @@ class RepoConfigLoader:
                         del prepos[repo_name]
                         continue
 
-                location_map[repo.location] = repo_name
-                treemap[repo_name] = repo.location
+                location_map[repo.location] = repo.name
+                treemap[repo.name] = repo.location
 
         # Add alias mappings, but never replace unaliased mappings.
         for repo_name, repo in list(prepos.items()):
             names = set()
-            names.add(repo_name)
+            names.add(repo.name)
             if repo.aliases:
                 aliases = stack_lists([repo.aliases], incremental=True)
                 names.update(aliases)

Reply via email to