summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2018-10-03 07:35:03 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-10-03 07:35:03 +0000
commit6e820362700e4083cb57a8b8603a20e373f30cee (patch)
treebca7a0089f6d049088ad8ed0f9ad3567c18544ec
parent764b75173609b90eacbc0b0165ab98c2d3fdf9a8 (diff)
parent7da5104b1e66f742337ac1bf0e740c5ef290e381 (diff)
downloadbuildstream-6e820362700e4083cb57a8b8603a20e373f30cee.tar.gz
Merge branch 'tristan/fix-status-messages-1.2' into 'bst-1.2'
fix status messages (1.2) See merge request BuildStream/buildstream!846
-rw-r--r--buildstream/plugins/sources/git.py16
-rw-r--r--buildstream/source.py54
2 files changed, 49 insertions, 21 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 065870169..de0376776 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -164,10 +164,18 @@ class GitMirror(SourceFetcher):
cwd=self.mirror)
def fetch(self, alias_override=None):
- self.ensure(alias_override)
- if not self.has_ref():
- self._fetch(alias_override)
- self.assert_ref()
+ # Resolve the URL for the message
+ resolved_url = self.source.translate_url(self.url,
+ alias_override=alias_override,
+ primary=self.primary)
+
+ with self.source.timed_activity("Fetching from {}"
+ .format(resolved_url),
+ silent_nested=True):
+ self.ensure(alias_override)
+ if not self.has_ref():
+ self._fetch(alias_override)
+ self.assert_ref()
def has_ref(self):
if not self.ref:
diff --git a/buildstream/source.py b/buildstream/source.py
index af9474904..b8759c0d8 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -585,28 +585,48 @@ class Source(Plugin):
#
def _fetch(self):
project = self._get_project()
- source_fetchers = self.get_source_fetchers()
+ context = self._get_context()
+
+ # Silence the STATUS messages which might happen as a result
+ # of checking the source fetchers.
+ with context.silence():
+ 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()
- for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
- try:
- fetcher.fetch(uri)
- # FIXME: Need to consider temporary vs. permanent failures,
- # and how this works with retries.
- except BstError as e:
- last_error = e
- continue
-
- # No error, we're done with this fetcher
- break
- else:
- # No break occurred, raise the last detected error
- raise last_error
+ # Use a contorted loop here, this is to allow us to
+ # silence the messages which can result from consuming
+ # the items of source_fetchers, if it happens to be a generator.
+ #
+ source_fetchers = iter(source_fetchers)
+ try:
+
+ while True:
+
+ with context.silence():
+ fetcher = next(source_fetchers)
+
+ alias = fetcher._get_alias()
+ for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
+ try:
+ fetcher.fetch(uri)
+ # FIXME: Need to consider temporary vs. permanent failures,
+ # and how this works with retries.
+ except BstError as e:
+ last_error = e
+ continue
+
+ # No error, we're done with this fetcher
+ break
+
+ else:
+ # No break occurred, raise the last detected error
+ raise last_error
+
+ except StopIteration:
+ pass
# Default codepath is to reinstantiate the Source
#