summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2018-10-03 08:07:15 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-10-03 08:07:15 +0000
commitc943761632c94274d3662b215b25ded0eeefc6fc (patch)
tree1e6a14381bf3586bee3d7e753173887bbe5cc224
parent66446fc343c7f324da0a2995e7190fb4569b35c9 (diff)
parentb645881cfa5f20d443a621824b45c4178e1cda2c (diff)
downloadbuildstream-c943761632c94274d3662b215b25ded0eeefc6fc.tar.gz
Merge branch 'tristan/fix-status-messages' into 'master'
fix status messages See merge request BuildStream/buildstream!845
-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 77db9534a..bce399cd9 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -184,10 +184,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 5324f42a8..6768f6cfc 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -965,28 +965,48 @@ class Source(Plugin):
# Tries to call fetch for every mirror, stopping once it succeeds
def __do_fetch(self, **kwargs):
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
#