You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:28:28 UTC

[buildstream] branch gokcen/add_no_fetch_flag created (now c491d11)

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

tvb pushed a change to branch gokcen/add_no_fetch_flag
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at c491d11  fixup! Make source-checkout fetch by default

This branch includes the following new commits:

     new e23c138  Add no-fetch flag for 'bst pull' command
     new 8fe2930  Add no-fetch flag for 'bst push' command
     new cd3e029  Add no-fetch flag for 'bst track' command
     new c351a3a  Add no-fetch flag for 'bst checkout' command
     new 633911e  Add no-fetch flag for 'bst source-bundle'
     new e0dac1d  Add no-fetch flag for 'bst workspace-open'
     new 0a2c52c  Add no-fetch flag for 'bst workspace-reset'
     new af2bf4a  Make source-checkout fetch by default
     new c491d11  fixup! Make source-checkout fetch by default

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 02/09: Add no-fetch flag for 'bst push' command

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8fe2930f05316d96784bafc9870f17f969dbf271
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Thu Oct 25 18:38:44 2018 +0100

    Add no-fetch flag for 'bst push' command
---
 buildstream/_frontend/cli.py | 6 ++++--
 buildstream/_stream.py       | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index eac304f..6301fa5 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -464,8 +464,10 @@ def pull(app, elements, deps, remote, no_fetch):
               help="The URL of the remote cache (defaults to the first configured cache)")
 @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 junction(s)")
 @click.pass_obj
-def push(app, elements, deps, remote):
+def push(app, elements, deps, remote, no_fetch):
     """Push a built artifact to a remote artifact cache.
 
     The default destination is the highest priority configured cache. You can
@@ -478,7 +480,7 @@ def push(app, elements, deps, remote):
         all:   All dependencies
     """
     with app.initialized(session_name="Push"):
-        app.stream.push(elements, selection=deps, remote=remote)
+        app.stream.push(elements, selection=deps, remote=remote, no_fetch=no_fetch)
 
 
 ##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 992b37a..cd69808 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -325,13 +325,15 @@ class Stream():
     #    targets (list of str): Targets to push
     #    selection (PipelineSelection): The selection mode for the specified targets
     #    remote (str): The URL of a specific remote server to push to, or None
+    #    no_fetch (bool): Flag to disable auto-fetch of junctions needed by `targets`
     #
     # If `remote` specified as None, then regular configuration will be used
     # to determine where to push artifacts to.
     #
     def push(self, targets, *,
              selection=PipelineSelection.NONE,
-             remote=None):
+             remote=None,
+             no_fetch):
 
         use_config = True
         if remote:
@@ -341,7 +343,7 @@ class Stream():
                                  selection=selection,
                                  use_artifact_config=use_config,
                                  artifact_remote_url=remote,
-                                 fetch_subprojects=True)
+                                 fetch_subprojects=not no_fetch)
 
         if not self._artifacts.has_push_remotes():
             raise StreamError("No artifact caches available for pushing artifacts")


[buildstream] 05/09: Add no-fetch flag for 'bst source-bundle'

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 633911efc36768c5587855157171b0aff6385bbd
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Mon Oct 29 11:37:46 2018 +0000

    Add no-fetch flag for 'bst source-bundle'
---
 buildstream/_frontend/cli.py |  7 +++++--
 buildstream/_stream.py       | 14 +++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 5d083ee..d733890 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -849,9 +849,11 @@ def workspace_list(app):
               help="The directory to write the tarball to")
 @click.argument('element',
                 type=click.Path(readable=False))
+@click.option('--no-fetch', 'no_fetch', default=False, is_flag=True,
+              help="Disable auto-fetching of junction(s)")
 @click.pass_obj
 def source_bundle(app, element, force, directory,
-                  track_, compression, except_):
+                  track_, compression, except_, no_fetch):
     """Produce a source bundle to be manually executed
     """
     with app.initialized():
@@ -859,4 +861,5 @@ def source_bundle(app, element, force, directory,
                                  track_first=track_,
                                  force=force,
                                  compression=compression,
-                                 except_targets=except_)
+                                 except_targets=except_,
+                                 no_fetch=no_fetch)
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 2e88d5a..bf0e66f 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -729,12 +729,15 @@ class Stream():
     #    track_first (bool): Track new source references before bundling
     #    compression (str): The compression type to use
     #    force (bool): Overwrite an existing tarball
+    #    no_fetch (bool): Flag to disable auto-fetch of `target` and junction(s)
+    #                     needed by `target`
     #
     def source_bundle(self, target, directory, *,
                       track_first=False,
                       force=False,
                       compression="gz",
-                      except_targets=()):
+                      except_targets=(),
+                      no_fetch):
 
         if track_first:
             track_targets = (target,)
@@ -745,7 +748,7 @@ class Stream():
                                               selection=PipelineSelection.ALL,
                                               except_targets=except_targets,
                                               track_selection=PipelineSelection.ALL,
-                                              fetch_subprojects=True)
+                                              fetch_subprojects=not no_fetch)
 
         # source-bundle only supports one target
         target = self.targets[0]
@@ -770,7 +773,12 @@ class Stream():
 
         # Fetch and possibly track first
         #
-        self._fetch(elements, track_elements=track_elements)
+        if not no_fetch:
+            self._fetch(elements, track_elements=track_elements)
+        else:
+            # No fetch, just tracking
+            self._fetch([], track_elements=track_elements)
+            self._pipeline.assert_sources_cached(elements)
 
         # We don't use the scheduler for this as it is almost entirely IO
         # bound.


[buildstream] 08/09: Make source-checkout fetch by default

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit af2bf4a7bb019d764e895bcb99ad5644aa69756b
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Fri Nov 23 17:05:53 2018 +0000

    Make source-checkout fetch by default
    
    This replaces `--fetch` with `--no-fetch`.
---
 buildstream/_frontend/cli.py | 8 ++++----
 buildstream/_stream.py       | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index d9ce8c5..8596bd6 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -684,20 +684,20 @@ def checkout(app, element, location, force, deps, integrate, hardlinks, tar, no_
 @click.option('--deps', '-d', default='none',
               type=click.Choice(['build', 'none', 'run', 'all']),
               help='The dependencies whose sources to checkout (default: none)')
-@click.option('--fetch', 'fetch_', default=False, is_flag=True,
-              help='Fetch elements if they are not fetched')
+@click.option('--no-fetch', 'no_fetch', default=False, is_flag=True,
+              help="Disable auto-fetching of element and related junction(s)")
 @click.argument('element',
                 type=click.Path(readable=False))
 @click.argument('location', type=click.Path())
 @click.pass_obj
-def source_checkout(app, element, location, deps, fetch_, except_):
+def source_checkout(app, element, location, deps, no_fetch, except_):
     """Checkout sources of an element to the specified location
     """
     with app.initialized():
         app.stream.source_checkout(element,
                                    location=location,
                                    deps=deps,
-                                   fetch=fetch_,
+                                   fetch=not no_fetch,
                                    except_targets=except_)
 
 
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 36086ed..67c861c 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -439,13 +439,13 @@ class Stream():
     #    target (str): The target element whose sources to checkout
     #    location (str): Location to checkout the sources to
     #    deps (str): The dependencies to checkout
-    #    fetch (bool): Whether to fetch missing sources
+    #    fetch (bool): Whether to fetch missing sources, including junction(s)
     #    except_targets (list): List of targets to except from staging
     #
     def source_checkout(self, target, *,
                         location=None,
                         deps='none',
-                        fetch=False,
+                        fetch=True,
                         except_targets=()):
 
         self._check_location_writable(location)
@@ -453,7 +453,7 @@ class Stream():
         elements, _ = self._load((target,), (),
                                  selection=deps,
                                  except_targets=except_targets,
-                                 fetch_subprojects=True)
+                                 fetch_subprojects=fetch)
 
         # Assert all sources are cached
         if fetch:


[buildstream] 03/09: Add no-fetch flag for 'bst track' command

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cd3e029ca3630fe74fdcd49d461cddee2a61cc34
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Fri Oct 26 10:32:34 2018 +0100

    Add no-fetch flag for 'bst track' command
---
 buildstream/_frontend/cli.py | 7 +++++--
 buildstream/_stream.py       | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 6301fa5..67464d7 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -397,8 +397,10 @@ def fetch(app, elements, deps, track_, except_, track_cross_junctions):
               help="Allow crossing junction boundaries")
 @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 junction(s)")
 @click.pass_obj
-def track(app, elements, deps, except_, cross_junctions):
+def track(app, elements, deps, except_, cross_junctions, no_fetch):
     """Consults the specified tracking branches for new versions available
     to build and updates the project with any newly available references.
 
@@ -419,7 +421,8 @@ def track(app, elements, deps, except_, cross_junctions):
         app.stream.track(elements,
                          selection=deps,
                          except_targets=except_,
-                         cross_junctions=cross_junctions)
+                         cross_junctions=cross_junctions,
+                         no_fetch=no_fetch)
 
 
 ##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index cd69808..72e4990 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -256,6 +256,7 @@ class Stream():
     #    selection (PipelineSelection): The selection mode for the specified targets
     #    except_targets (list of str): Specified targets to except from tracking
     #    cross_junctions (bool): Whether tracking should cross junction boundaries
+    #    no_fetch (bool): Flag to disable auto-fetch of junctions needed by `targets`
     #
     # If no error is encountered while tracking, then the project files
     # are rewritten inline.
@@ -263,7 +264,8 @@ class Stream():
     def track(self, targets, *,
               selection=PipelineSelection.REDIRECT,
               except_targets=None,
-              cross_junctions=False):
+              cross_junctions=False,
+              no_fetch):
 
         # We pass no target to build. Only to track. Passing build targets
         # would fully load project configuration which might not be
@@ -274,7 +276,7 @@ class Stream():
                        except_targets=except_targets,
                        track_except_targets=except_targets,
                        track_cross_junctions=cross_junctions,
-                       fetch_subprojects=True)
+                       fetch_subprojects=not no_fetch)
 
         track_queue = TrackQueue(self._scheduler)
         self._add_queue(track_queue, track=True)


[buildstream] 06/09: Add no-fetch flag for 'bst workspace-open'

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e0dac1d3cf296885a804401395a28d0e8b31490f
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Mon Oct 29 17:40:31 2018 +0000

    Add no-fetch flag for 'bst workspace-open'
---
 buildstream/_frontend/cli.py |  7 +++++--
 buildstream/_stream.py       | 20 +++++++++++---------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index d733890..6837965 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 bf0e66f..6fda881 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))


[buildstream] 01/09: Add no-fetch flag for 'bst pull' command

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e23c138225eb657a29ef6ee3d560a75aa12a7797
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Thu Oct 25 18:30:36 2018 +0100

    Add no-fetch flag for 'bst pull' command
---
 buildstream/_frontend/cli.py | 6 ++++--
 buildstream/_stream.py       | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index b1b4e03..eac304f 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -433,8 +433,10 @@ def track(app, elements, deps, except_, cross_junctions):
               help="The URL of the remote cache (defaults to the first configured cache)")
 @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 junction(s)")
 @click.pass_obj
-def pull(app, elements, deps, remote):
+def pull(app, elements, deps, remote, no_fetch):
     """Pull a built artifact from the configured remote artifact cache.
 
     By default the artifact will be pulled one of the configured caches
@@ -448,7 +450,7 @@ def pull(app, elements, deps, remote):
         all:   All dependencies
     """
     with app.initialized(session_name="Pull"):
-        app.stream.pull(elements, selection=deps, remote=remote)
+        app.stream.pull(elements, selection=deps, remote=remote, no_fetch=no_fetch)
 
 
 ##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 76f1d67..992b37a 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -289,13 +289,15 @@ class Stream():
     #    targets (list of str): Targets to pull
     #    selection (PipelineSelection): The selection mode for the specified targets
     #    remote (str): The URL of a specific remote server to pull from, or None
+    #    no_fetch (bool): Flag to disable auto-fetch of junctions needed by `targets`
     #
     # If `remote` specified as None, then regular configuration will be used
     # to determine where to pull artifacts from.
     #
     def pull(self, targets, *,
              selection=PipelineSelection.NONE,
-             remote=None):
+             remote=None,
+             no_fetch):
 
         use_config = True
         if remote:
@@ -305,7 +307,7 @@ class Stream():
                                  selection=selection,
                                  use_artifact_config=use_config,
                                  artifact_remote_url=remote,
-                                 fetch_subprojects=True)
+                                 fetch_subprojects=not no_fetch)
 
         if not self._artifacts.has_fetch_remotes():
             raise StreamError("No artifact caches available for pulling artifacts")


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

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0a2c52c620555fcfbdd9c7ed48cd22abe9dfa1f9
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 6837965..d9ce8c5 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..36086ed 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
+    #    no_fetch (bool): Disable auto-fetching of targets 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()
 


[buildstream] 04/09: Add no-fetch flag for 'bst checkout' command

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c351a3a7a03f68cedc634044b837fb301bb8c103
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Fri Oct 26 10:48:39 2018 +0100

    Add no-fetch flag for 'bst checkout' command
---
 buildstream/_frontend/cli.py | 7 +++++--
 buildstream/_stream.py       | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 67464d7..5d083ee 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -652,8 +652,10 @@ def shell(app, element, sysroot, mount, isolate, build_, command):
 @click.argument('element',
                 type=click.Path(readable=False))
 @click.argument('location', type=click.Path())
+@click.option('--no-fetch', 'no_fetch', default=False, is_flag=True,
+              help="Disable auto-fetching of junction(s)")
 @click.pass_obj
-def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
+def checkout(app, element, location, force, deps, integrate, hardlinks, tar, no_fetch):
     """Checkout a built artifact to the specified location
     """
 
@@ -668,7 +670,8 @@ def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
                             deps=deps,
                             integrate=integrate,
                             hardlinks=hardlinks,
-                            tar=tar)
+                            tar=tar,
+                            no_fetch=no_fetch)
 
 
 ##################################################################
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 72e4990..2e88d5a 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -372,6 +372,7 @@ class Stream():
     #                will be placed at the given location. If true and
     #                location is '-', the tarball will be dumped on the
     #                standard output.
+    #    no_fetch (bool): Flag to disable auto-fetch of junctions needed by `target`
     #
     def checkout(self, target, *,
                  location=None,
@@ -379,10 +380,11 @@ class Stream():
                  deps='run',
                  integrate=True,
                  hardlinks=False,
-                 tar=False):
+                 tar=False,
+                 no_fetch):
 
         # We only have one target in a checkout command
-        elements, _ = self._load((target,), (), fetch_subprojects=True)
+        elements, _ = self._load((target,), (), fetch_subprojects=not no_fetch)
         target = elements[0]
 
         self._check_location_writable(location, force=force, tar=tar)


[buildstream] 09/09: fixup! Make source-checkout fetch by default

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c491d1125c55d19b55df6674231d0e360f5437ac
Author: Gökçen Nurlu <gn...@bloomberg.net>
AuthorDate: Fri Nov 23 17:53:34 2018 +0000

    fixup! Make source-checkout fetch by default
---
 tests/frontend/source_checkout.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/frontend/source_checkout.py b/tests/frontend/source_checkout.py
index 58dfdbd..af144f6 100644
--- a/tests/frontend/source_checkout.py
+++ b/tests/frontend/source_checkout.py
@@ -91,8 +91,8 @@ def test_source_checkout_except(datafiles, cli):
 
 
 @pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize('fetch', [(False), (True)])
-def test_source_checkout_fetch(datafiles, cli, fetch):
+@pytest.mark.parametrize('no_fetch', [(False), (True)])
+def test_source_checkout_fetch(datafiles, cli, no_fetch):
     project = os.path.join(datafiles.dirname, datafiles.basename)
     checkout = os.path.join(cli.directory, 'source-checkout')
     target = 'remote-import-dev.bst'
@@ -104,18 +104,18 @@ def test_source_checkout_fetch(datafiles, cli, fetch):
         'pony.h')
     _yaml.dump(element, target_path)
 
-    # Testing --fetch option requires that we do not have the sources
+    # Testing --no-fetch option requires that we do not have the sources
     # cached already
     assert cli.get_element_state(project, target) == 'fetch needed'
 
     args = ['source-checkout']
-    if fetch:
-        args += ['--fetch']
+    if no_fetch:
+        args += ['--no-fetch']
     args += [target, checkout]
     result = cli.run(project=project, args=args)
 
-    if fetch:
+    if no_fetch:
+        result.assert_main_error(ErrorDomain.PIPELINE, 'uncached-sources')
+    else:
         result.assert_success()
         assert os.path.exists(os.path.join(checkout, 'remote-import-dev', 'pony.h'))
-    else:
-        result.assert_main_error(ErrorDomain.PIPELINE, 'uncached-sources')