summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGökçen Nurlu <gnurlu1@bloomberg.net>2018-10-29 17:40:31 +0000
committerGökçen Nurlu <gnurlu1@bloomberg.net>2018-11-23 16:19:50 +0000
commite0dac1d3cf296885a804401395a28d0e8b31490f (patch)
tree916980c45ccfde55bfaadb508bd307c9bf172f27
parent633911efc36768c5587855157171b0aff6385bbd (diff)
downloadbuildstream-e0dac1d3cf296885a804401395a28d0e8b31490f.tar.gz
Add no-fetch flag for 'bst workspace-open'
-rw-r--r--buildstream/_frontend/cli.py7
-rw-r--r--buildstream/_stream.py20
2 files changed, 16 insertions, 11 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index d7338904b..68379659b 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -724,8 +724,10 @@ def workspace():
@click.option('--directory', type=click.Path(file_okay=False), default=None,
help="Only for use when a single Element is given: Set the directory to use to create the workspace")
@click.argument('elements', nargs=-1, type=click.Path(readable=False), required=True)
+@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_open(app, no_checkout, force, track_, directory, elements):
+def workspace_open(app, no_checkout, force, track_, directory, elements, no_fetch):
"""Open a workspace for manual source modification"""
with app.initialized():
@@ -733,7 +735,8 @@ def workspace_open(app, no_checkout, force, track_, directory, elements):
no_checkout=no_checkout,
track_first=track_,
force=force,
- custom_dir=directory)
+ custom_dir=directory,
+ no_fetch=no_fetch)
##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index bf0e66f43..6fda88169 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -477,12 +477,14 @@ class Stream():
# track_first (bool): Whether to track and fetch first
# force (bool): Whether to ignore contents in an existing directory
# custom_dir (str): Custom location to create a workspace or false to use default location.
+ # no_fetch (bool): Disable auto-fetching of targets and related junction(s)
#
def workspace_open(self, targets, *,
no_checkout,
track_first,
force,
- custom_dir):
+ custom_dir,
+ no_fetch):
# This function is a little funny but it is trying to be as atomic as possible.
if track_first:
@@ -492,14 +494,14 @@ 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)
workspaces = self._context.get_workspaces()
- # If we're going to checkout, we need at least a fetch,
- # if we were asked to track first, we're going to fetch anyway.
+ # If we're going to checkout and we aren't explicitly told not to fetch
#
- if not no_checkout or track_first:
+ if not no_checkout and not no_fetch:
track_elements = []
if track_first:
track_elements = elements
@@ -523,11 +525,11 @@ class Stream():
raise StreamError("Element '{}' already has workspace defined at: {}"
.format(target.name, workspace.get_absolute_path()))
- if not no_checkout and target._get_consistency() != Consistency.CACHED:
+ # In case of `--no-fetch` flag, check if sources are available
+ if no_fetch and not no_checkout and target._get_consistency() != Consistency.CACHED:
raise StreamError("Could not stage uncached source. For {} ".format(target.name) +
- "Use `--track` to track and " +
- "fetch the latest version of the " +
- "source.")
+ "remove `--no-fetch` to automatically fetch and optionally add " +
+ "`--track` to update its ref and fetch the latest version.")
if not custom_dir:
directory = os.path.abspath(os.path.join(self._context.workspacedir, target.name))