Tristan Van Berkom pushed to branch master at BuildStream / buildstream
Commits:
-
29c19bea
by Tristan Van Berkom at 2018-10-03T07:33:48Z
-
b645881c
by Tristan Van Berkom at 2018-10-03T07:33:48Z
-
c9437616
by Tristan Van Berkom at 2018-10-03T08:07:15Z
2 changed files:
Changes:
| ... | ... | @@ -184,10 +184,18 @@ class GitMirror(SourceFetcher): |
| 184 | 184 |
cwd=self.mirror)
|
| 185 | 185 |
|
| 186 | 186 |
def fetch(self, alias_override=None):
|
| 187 |
- self.ensure(alias_override)
|
|
| 188 |
- if not self.has_ref():
|
|
| 189 |
- self._fetch(alias_override)
|
|
| 190 |
- self.assert_ref()
|
|
| 187 |
+ # Resolve the URL for the message
|
|
| 188 |
+ resolved_url = self.source.translate_url(self.url,
|
|
| 189 |
+ alias_override=alias_override,
|
|
| 190 |
+ primary=self.primary)
|
|
| 191 |
+ |
|
| 192 |
+ with self.source.timed_activity("Fetching from {}"
|
|
| 193 |
+ .format(resolved_url),
|
|
| 194 |
+ silent_nested=True):
|
|
| 195 |
+ self.ensure(alias_override)
|
|
| 196 |
+ if not self.has_ref():
|
|
| 197 |
+ self._fetch(alias_override)
|
|
| 198 |
+ self.assert_ref()
|
|
| 191 | 199 |
|
| 192 | 200 |
def has_ref(self):
|
| 193 | 201 |
if not self.ref:
|
| ... | ... | @@ -965,28 +965,48 @@ class Source(Plugin): |
| 965 | 965 |
# Tries to call fetch for every mirror, stopping once it succeeds
|
| 966 | 966 |
def __do_fetch(self, **kwargs):
|
| 967 | 967 |
project = self._get_project()
|
| 968 |
- source_fetchers = self.get_source_fetchers()
|
|
| 968 |
+ context = self._get_context()
|
|
| 969 |
+ |
|
| 970 |
+ # Silence the STATUS messages which might happen as a result
|
|
| 971 |
+ # of checking the source fetchers.
|
|
| 972 |
+ with context.silence():
|
|
| 973 |
+ source_fetchers = self.get_source_fetchers()
|
|
| 969 | 974 |
|
| 970 | 975 |
# Use the source fetchers if they are provided
|
| 971 | 976 |
#
|
| 972 | 977 |
if source_fetchers:
|
| 973 |
- for fetcher in source_fetchers:
|
|
| 974 |
- alias = fetcher._get_alias()
|
|
| 975 |
- for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
|
|
| 976 |
- try:
|
|
| 977 |
- fetcher.fetch(uri)
|
|
| 978 |
- # FIXME: Need to consider temporary vs. permanent failures,
|
|
| 979 |
- # and how this works with retries.
|
|
| 980 |
- except BstError as e:
|
|
| 981 |
- last_error = e
|
|
| 982 |
- continue
|
|
| 983 |
- |
|
| 984 |
- # No error, we're done with this fetcher
|
|
| 985 |
- break
|
|
| 986 | 978 |
|
| 987 |
- else:
|
|
| 988 |
- # No break occurred, raise the last detected error
|
|
| 989 |
- raise last_error
|
|
| 979 |
+ # Use a contorted loop here, this is to allow us to
|
|
| 980 |
+ # silence the messages which can result from consuming
|
|
| 981 |
+ # the items of source_fetchers, if it happens to be a generator.
|
|
| 982 |
+ #
|
|
| 983 |
+ source_fetchers = iter(source_fetchers)
|
|
| 984 |
+ try:
|
|
| 985 |
+ |
|
| 986 |
+ while True:
|
|
| 987 |
+ |
|
| 988 |
+ with context.silence():
|
|
| 989 |
+ fetcher = next(source_fetchers)
|
|
| 990 |
+ |
|
| 991 |
+ alias = fetcher._get_alias()
|
|
| 992 |
+ for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
|
|
| 993 |
+ try:
|
|
| 994 |
+ fetcher.fetch(uri)
|
|
| 995 |
+ # FIXME: Need to consider temporary vs. permanent failures,
|
|
| 996 |
+ # and how this works with retries.
|
|
| 997 |
+ except BstError as e:
|
|
| 998 |
+ last_error = e
|
|
| 999 |
+ continue
|
|
| 1000 |
+ |
|
| 1001 |
+ # No error, we're done with this fetcher
|
|
| 1002 |
+ break
|
|
| 1003 |
+ |
|
| 1004 |
+ else:
|
|
| 1005 |
+ # No break occurred, raise the last detected error
|
|
| 1006 |
+ raise last_error
|
|
| 1007 |
+ |
|
| 1008 |
+ except StopIteration:
|
|
| 1009 |
+ pass
|
|
| 990 | 1010 |
|
| 991 | 1011 |
# Default codepath is to reinstantiate the Source
|
| 992 | 1012 |
#
|
