From 68b441956fda07c2d73d530f2e491a1948aa7eb8 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 30 Aug 2018 17:51:20 +0900 Subject: source.py: Stylistic changes in Source.__do_fetch() Added some comments to make the flow easier to follow, and removed an annoying 'success' variabled in favor of a for / else loop statement. --- buildstream/source.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/buildstream/source.py b/buildstream/source.py index 79d9e014f..7b28c3df8 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -517,10 +517,12 @@ class Source(Plugin): def _fetch(self): 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) @@ -529,10 +531,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: @@ -556,7 +564,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 # Wrapper for stage() api which gives the source -- cgit v1.2.1 From 88bdf22ae9b2a33a53138517d2dbefcc7900e8ae Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 30 Aug 2018 15:27:39 +0900 Subject: source.py: Move Source.mark_download_url() to the public methods. This was sitting in the section for abstract methods, but this is most definitely not an abstract method to be implemented by Sources. --- buildstream/source.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/buildstream/source.py b/buildstream/source.py index 7b28c3df8..8caca4a91 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -372,19 +372,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 @@ -453,6 +440,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 -- cgit v1.2.1 From 813fcd60915a894ee9d8ced15ed282b7f763aaaa Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 30 Aug 2018 15:56:23 +0900 Subject: plugins/source/git.py: Fix formatting of url in tracking This was displaying the aliased URL which is pretty useless, use the translated URL for the timed activity. --- buildstream/plugins/sources/git.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py index 56bf40e00..354f80b5d 100644 --- a/buildstream/plugins/sources/git.py +++ b/buildstream/plugins/sources/git.py @@ -368,8 +368,10 @@ class GitSource(Source): if not self.tracking: 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() -- cgit v1.2.1