This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/mirror-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 9f05c0d8648a86e759a2fbe36d3cba3eda9d293e
Author: Tristan van Berkom <[email protected]>
AuthorDate: Wed Nov 1 16:07:35 2023 +0900

    WIP debugging
---
 src/buildstream/_project.py     |  6 +++---
 src/buildstream/source.py       | 12 ++++++++++--
 src/buildstream/sourcemirror.py | 16 ++++++++++++----
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 2ed6fb348..22aba8cbe 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -412,7 +412,7 @@ class Project:
     #
     def get_alias_uris(
         self, alias: str, *, first_pass: bool = False, tracking: bool = False
-    ) -> List[Tuple[Optional[SourceMirror], str]]:
+    ) -> List[Tuple[Optional[SourceMirror], Optional[str]]]:
 
         if first_pass:
             config = self.first_pass_config
@@ -420,9 +420,9 @@ class Project:
             config = self.config
 
         if not alias or alias not in config._aliases:  # pylint: 
disable=unsupported-membership-test
-            return []
+            return [(None, None)]
 
-        uri_list: List[Tuple[Optional[SourceMirror], str]] = []
+        uri_list: List[Tuple[Optional[SourceMirror], Optional[str]]] = []
         policy = self._context.track_source if tracking else 
self._context.fetch_source
 
         if policy in (_SourceUriPolicy.ALL, _SourceUriPolicy.MIRRORS) or (
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 509be7445..70c61d607 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -740,9 +740,9 @@ class Source(Plugin):
         # Alias overriding can happen explicitly (by command-line) or
         # implicitly (the Source being constructed with an __alias_override).
         #
-        if alias_override or self.__alias_override:
+        if self.__active_mirror is not None:
 
-            assert self.__active_mirror is not None
+            assert (alias_override or self.__alias_override)
 
             url_alias, url_body = url.split(utils._ALIAS_SEPARATOR, 1)
             project_alias_url = project.get_alias_url(url_alias, 
first_pass=self.__first_pass)
@@ -756,6 +756,10 @@ class Source(Plugin):
                 # URLs and use different aliases default to only overriding
                 # one alias, rather than getting confused.
                 #
+                # XXX Is this behavior still going to be correct with 
SourceMirror plugins ?
+                #
+                # It seems we should not allow any URIs to escape the 
SourceMirror plugin filtering.
+                #
                 if url_alias != override_alias:
                     return url
 
@@ -1446,6 +1450,10 @@ class Source(Plugin):
                 else:
                     # No break occurred, raise the last detected error
                     self.__active_mirror = None
+
+                    import sys
+                    sys.stderr.write("\n\nERROR: {}\n\n".format(last_error))
+
                     raise last_error
 
         # Default codepath is to reinstantiate the Source
diff --git a/src/buildstream/sourcemirror.py b/src/buildstream/sourcemirror.py
index 842ea15d8..6729c0c0c 100644
--- a/src/buildstream/sourcemirror.py
+++ b/src/buildstream/sourcemirror.py
@@ -103,10 +103,10 @@ class SourceMirror(Plugin):
         project: "Project",
         node: MappingNode,
     ):
-        # First perform variable substitutions
-        node = node.clone()
-        project.base_variables.expand(node)
-
+        # Note: the MappingNode passed here is already expanded with
+        #       the project level base variables, so there is no need
+        #       to expand them redundantly here.
+        #
         node.validate_keys(["name", "kind", "config", "aliases"])
 
         # Do local base class parsing first
@@ -116,6 +116,10 @@ class SourceMirror(Plugin):
         # Chain up to Plugin
         super().__init__(name, context, project, node, "source-mirror")
 
+        # XXX
+        import sys
+        sys.stderr.write("\n\n\nMirror '{}': {}\n\n\n\n".format(self.name, 
self.__aliases))
+        
         # Plugin specific parsing
         config = node.get_mapping("config", default={})
         self._configure(config)
@@ -139,6 +143,10 @@ class SourceMirror(Plugin):
         #
         assert alias_substitute_url is not None
 
+        # XXX
+        import sys
+        sys.stderr.write("\n\n\nMirror '{}': translate_url for alias '{}': 
{}\n\n\n\n".format(self.name, alias, alias_substitute_url + source_url))
+
         return alias_substitute_url + source_url
 
     #############################################################

Reply via email to