summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGökçen Nurlu <gnurlu1@bloomberg.net>2018-10-29 18:44:21 +0000
committerGökçen Nurlu <gnurlu1@bloomberg.net>2018-10-29 18:44:21 +0000
commit7951f7f6171cc201451ee696f69e2820638a9e8b (patch)
treef5569b79964ee36fb4f5e1906e91d74e06308f51
parent0ad43c10ab467fef6e04813b9da0ca42c2d86eea (diff)
downloadbuildstream-no_auto_fetch.tar.gz
Add explicit fetch flag for 'bst workspace-reset'no_auto_fetch
-rw-r--r--buildstream/_frontend/cli.py6
-rw-r--r--buildstream/_stream.py19
2 files changed, 19 insertions, 6 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index b73771165..07880f9bd 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -777,8 +777,10 @@ def workspace_close(app, remove_dir, all_, elements):
help="Reset all open workspaces")
@click.argument('elements', nargs=-1,
type=click.Path(readable=False))
+@click.option('--fetch', 'fetch_', default=False, is_flag=True,
+ help="Enable auto-fetching of element and related junction(s)")
@click.pass_obj
-def workspace_reset(app, soft, track_, all_, elements):
+def workspace_reset(app, soft, track_, all_, elements, fetch_):
"""Reset a workspace to its original state"""
# Check that the workspaces in question exist
@@ -798,7 +800,7 @@ def workspace_reset(app, soft, track_, all_, elements):
if all_:
elements = tuple(element_name for element_name, _ in app.context.get_workspaces().list())
- app.stream.workspace_reset(elements, soft=soft, track_first=track_)
+ app.stream.workspace_reset(elements, soft=soft, track_first=track_, fetch=fetch_)
##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 14398b90d..2580134e3 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -560,8 +560,9 @@ class Stream():
# targets (list of str): The target elements to reset the workspace for
# soft (bool): Only reset workspace state
# track_first (bool): Whether to also track the sources first
+ # fetch (bool): Enable auto-fetching of target and related junction(s)
#
- def workspace_reset(self, targets, *, soft, track_first):
+ def workspace_reset(self, targets, *, soft, track_first, fetch):
if track_first:
track_targets = targets
@@ -570,7 +571,8 @@ class Stream():
elements, track_elements = self._load(targets, track_targets,
selection=PipelineSelection.REDIRECT,
- track_selection=PipelineSelection.REDIRECT)
+ track_selection=PipelineSelection.REDIRECT,
+ fetch_subprojects=fetch)
nonexisting = []
for element in elements:
@@ -579,9 +581,18 @@ class Stream():
if nonexisting:
raise StreamError("Workspace does not exist", detail="\n".join(nonexisting))
- # Do the tracking first
+ to_track = []
if track_first:
- self._fetch(elements, track_elements=track_elements)
+ to_track = track_elements
+
+ to_fetch = []
+ if fetch:
+ to_fetch = elements
+
+ if to_fetch or to_track:
+ self._fetch(to_fetch, track_elements=to_track)
+
+ self._pipeline.assert_sources_cached(elements)
workspaces = self._context.get_workspaces()