@@ -50,14 +50,13 @@ def __init__(
5050 prefixed_mappings: Dict mapping (source_prefix, target_apparent) -> target_canonical
5151 """
5252 self ._exact_mappings = exact_mappings
53- self ._prefixed_mappings = prefixed_mappings
5453
5554 # Group prefixed mappings by target_apparent for faster lookups
5655 self ._grouped_prefixed_mappings = defaultdict (list )
5756 for (
5857 prefix_source ,
5958 target_app ,
60- ), target_canonical in self . _prefixed_mappings .items ():
59+ ), target_canonical in prefixed_mappings .items ():
6160 self ._grouped_prefixed_mappings [target_app ].append (
6261 (prefix_source , target_canonical )
6362 )
@@ -138,7 +137,7 @@ def is_empty(self) -> bool:
138137 Returns:
139138 True if there are no mappings, False otherwise
140139 """
141- return len (self ._exact_mappings ) == 0 and len (self ._prefixed_mappings ) == 0
140+ return len (self ._exact_mappings ) == 0 and len (self ._grouped_prefixed_mappings ) == 0
142141
143142
144143class _ManifestBased :
@@ -306,7 +305,8 @@ def Rlocation(self, path: str, source_repo: Optional[str] = None) -> Optional[st
306305 # Split off the first path component, which contains the repository
307306 # name (apparent or canonical).
308307 target_repo , _ , remainder = path .partition ("/" )
309- if not remainder or self ._repo_mapping .lookup (source_repo , target_repo ) is None :
308+ target_canonical = self ._repo_mapping .lookup (source_repo , target_repo )
309+ if not remainder or target_canonical is None :
310310 # One of the following is the case:
311311 # - not using Bzlmod, so the repository mapping is empty and
312312 # apparent and canonical repository names are the same
@@ -321,12 +321,10 @@ def Rlocation(self, path: str, source_repo: Optional[str] = None) -> Optional[st
321321 ), "BUG: if the `source_repo` is None, we should never go past the `if` statement above"
322322
323323 # Look up the target repository using the repository mapping
324- if source_repo is not None :
325- target_canonical = self ._repo_mapping .lookup (source_repo , target_repo )
326- if target_canonical is not None :
327- return self ._strategy .RlocationChecked (
328- target_canonical + "/" + remainder
329- )
324+ if target_canonical is not None :
325+ return self ._strategy .RlocationChecked (
326+ target_canonical + "/" + remainder
327+ )
330328
331329 # No mapping found - assume target_repo is already canonical or
332330 # we're not using Bzlmod
0 commit comments