diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2018-08-30 09:12:28 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2018-08-30 09:12:28 +0000 |
commit | 26565f11b8dba375e21bf56af0ccf0092a8f8365 (patch) | |
tree | e86e0535528e069714df94243682f8bdafd61849 | |
parent | 8aec11026c266d0f3dc1f04bf83c09c2e823d95d (diff) | |
parent | c339f9176881c0afd3e26faaec0d1ecf4b71bc12 (diff) | |
download | buildstream-26565f11b8dba375e21bf56af0ccf0092a8f8365.tar.gz |
Merge branch 'tristan/source-mirroring-changes' into 'master'
Minor code changes revolving around source mirroring
See merge request BuildStream/buildstream!758
-rw-r--r-- | buildstream/plugins/sources/git.py | 4 | ||||
-rw-r--r-- | buildstream/source.py | 44 |
2 files changed, 31 insertions, 17 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py index b3bc9cac7..da5563782 100644 --- a/buildstream/plugins/sources/git.py +++ b/buildstream/plugins/sources/git.py @@ -387,8 +387,10 @@ class GitSource(Source): detail=detail, reason="track-attempt-no-track") return None + # Resolve the URL for the message + resolved_url = self.translate_url(self.mirror.url) with self.timed_activity("Tracking {} from {}" - .format(self.tracking, self.mirror.url), + .format(self.tracking, resolved_url), silent_nested=True): self.mirror.ensure() self.mirror._fetch() diff --git a/buildstream/source.py b/buildstream/source.py index a9ae090a5..b86f3fb16 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -445,19 +445,6 @@ class Source(Plugin): """ self.stage(directory) - def mark_download_url(self, url): - """Identifies the URL that this Source uses to download - - This must be called during :func:`~buildstream.plugin.Plugin.configure` if - :func:`~buildstream.source.Source.translate_url` is not called. - - Args: - url (str): The url used to download - - *Since: 1.2* - """ - self.__expected_alias = _extract_alias(url) - def get_source_fetchers(self): """Get the objects that are used for fetching @@ -526,6 +513,19 @@ class Source(Plugin): project = self._get_project() return project.translate_url(url, first_pass=self.__first_pass) + def mark_download_url(self, url): + """Identifies the URL that this Source uses to download + + This must be called during :func:`~buildstream.plugin.Plugin.configure` if + :func:`~buildstream.source.Source.translate_url` is not called. + + Args: + url (str): The url used to download + + *Since: 1.2* + """ + self.__expected_alias = _extract_alias(url) + def get_project_directory(self): """Fetch the project base directory @@ -865,10 +865,12 @@ class Source(Plugin): def __do_fetch(self, **kwargs): project = self._get_project() source_fetchers = self.get_source_fetchers() + + # Use the source fetchers if they are provided + # if source_fetchers: for fetcher in source_fetchers: alias = fetcher._get_alias() - success = False for uri in project.get_alias_uris(alias, first_pass=self.__first_pass): try: fetcher.fetch(uri) @@ -877,10 +879,16 @@ class Source(Plugin): except BstError as e: last_error = e continue - success = True + + # No error, we're done with this fetcher break - if not success: + + else: + # No break occurred, raise the last detected error raise last_error + + # Default codepath is to reinstantiate the Source + # else: alias = self._get_alias() if self.__first_pass: @@ -904,7 +912,11 @@ class Source(Plugin): except BstError as e: last_error = e continue + + # No error, we're done here return + + # Re raise the last detected error raise last_error # Tries to call track for every mirror, stopping once it succeeds |