You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:40:40 UTC

[buildstream] 07/07: Add no-fetch flag for 'bst workspace-reset'

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch gokcen/no_auto_fetch
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 1c45f7272f2ffe865c3c37d64e4f242817f81e6a
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Mon Oct 29 18:44:21 2018 +0000

    Add no-fetch flag for 'bst workspace-reset'
---
 buildstream/_frontend/cli.py |  6 ++++--
 buildstream/_stream.py       | 19 +++++++++++++++----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index ec0fbef..d2801f5 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -798,8 +798,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('--no-fetch', 'no_fetch', default=False, is_flag=True,
+              help="Disable auto-fetching of elements and related junction(s)")
 @click.pass_obj
-def workspace_reset(app, soft, track_, all_, elements):
+def workspace_reset(app, soft, track_, all_, elements, no_fetch):
     """Reset a workspace to its original state"""
 
     # Check that the workspaces in question exist
@@ -819,7 +821,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_, no_fetch=no_fetch)
 
 
 ##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 6fda881..98f3fcc 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -626,8 +626,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, no_fetch):
 
         if track_first:
             track_targets = targets
@@ -636,7 +637,8 @@ class Stream():
 
         elements, track_elements = self._load(targets, track_targets,
                                               selection=PipelineSelection.REDIRECT,
-                                              track_selection=PipelineSelection.REDIRECT)
+                                              track_selection=PipelineSelection.REDIRECT,
+                                              fetch_subprojects=not no_fetch)
 
         nonexisting = []
         for element in elements:
@@ -645,9 +647,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 not no_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()