summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-11-25 17:22:52 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2019-11-25 18:34:43 +0000
commita9286616a31304ae4a75f598bec3430c1a06426d (patch)
treed66aff9bc1693b581ba174e9dca735df66d960a3
parente516e1c065b5129630fd62c2115be1ea8bd7d658 (diff)
downloadbuildstream-a9286616a31304ae4a75f598bec3430c1a06426d.tar.gz
_stream.py: Remove dead code and comments about tracking
We don't have many of the `--track` options anymore, so we can remove handling for them in parts of the code that don't need it.
-rw-r--r--NEWS1
-rw-r--r--src/buildstream/_frontend/cli.py17
-rw-r--r--src/buildstream/_stream.py27
-rw-r--r--src/buildstream/plugins/elements/junction.py15
-rw-r--r--src/buildstream/testing/_sourcetests/workspace.py29
5 files changed, 23 insertions, 66 deletions
diff --git a/NEWS b/NEWS
index 2639dabfb..b27828cd0 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ CLI
* `bst source fetch --track`
* `bst source fetch --track-cross-junctions` / `bst source fetch -J`
* `bst workspace open --track`
+ * `bst workspace reset --track`
API
---
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 10ad23bb7..051f5d7f7 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -177,13 +177,7 @@ def override_completions(orig_args, cmd, cmd_param, args, incomplete):
# modifying click itself, so just do some weak special casing
# right here and select which parameters we want to handle specially.
if isinstance(cmd_param.type, click.Path):
- if (
- cmd_param.name == "elements"
- or cmd_param.name == "element"
- or cmd_param.name == "except_"
- or cmd_param.opts == ["--track"]
- or cmd_param.opts == ["--track-except"]
- ):
+ if cmd_param.name == "elements" or cmd_param.name == "element" or cmd_param.name == "except_":
return complete_target(args, incomplete)
if cmd_param.name == "artifacts" or cmd_param.name == "target":
return complete_artifact(orig_args, args, incomplete)
@@ -1026,11 +1020,10 @@ def workspace_close(app, remove_dir, all_, elements):
is_flag=True,
help="Mark workspace to re-execute configuration steps (if any) on next build. Does not alter workspace contents.",
)
-@click.option("--track", "track_", is_flag=True, help="Track and fetch the latest source before resetting")
@click.option("--all", "-a", "all_", is_flag=True, help="Reset all open workspaces")
@click.argument("elements", nargs=-1, type=click.Path(readable=False))
@click.pass_obj
-def workspace_reset(app, soft, track_, all_, elements):
+def workspace_reset(app, soft, all_, elements):
"""Reset a workspace to its original state"""
# Check that the workspaces in question exist
@@ -1049,7 +1042,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)
##################################################################
@@ -1437,11 +1430,9 @@ def artifact_delete(app, artifacts, deps):
type=click.Choice(["none", "plan", "all"]),
help="The dependencies to fetch",
)
-@click.option("--track", "track_", is_flag=True, help="Track new source references before fetching")
-@click.option("--track-cross-junctions", "-J", is_flag=True, help="Allow tracking to cross junction boundaries")
@click.argument("elements", nargs=-1, type=click.Path(readable=False))
@click.pass_obj
-def fetch(app, elements, deps, track_, except_, track_cross_junctions):
+def fetch(app, elements, deps, except_):
click.echo("This command is now obsolete. Use `bst source fetch` instead.", err=True)
sys.exit(1)
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index bab5cb100..86664de96 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -54,7 +54,7 @@ from ._state import State
from .types import _KeyStrength, _SchedulerErrorAction
from .plugin import Plugin
from . import utils, _yaml, _site
-from . import Scope, Consistency
+from . import Scope
# Stream()
@@ -98,7 +98,6 @@ class Stream:
self._scheduler = Scheduler(
context, session_start, self._state, self._notification_queue, self._scheduler_notification_handler
)
- self._first_non_track_queue = None
self._session_start_callback = session_start_callback
self._ticker_callback = ticker_callback
self._interrupt_callback = interrupt_callback
@@ -768,7 +767,6 @@ class Stream:
# Args:
# targets (list): List of target elements to open workspaces for
# no_checkout (bool): Whether to skip checking out the source
- # 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.
#
@@ -780,7 +778,6 @@ class Stream:
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 not no_checkout:
self._fetch(elements, fetch_original=True)
@@ -814,15 +811,6 @@ class Stream:
)
self.workspace_close(target._get_full_name(), remove_dir=not no_checkout)
- target_consistency = target._get_consistency()
- if not no_checkout and target_consistency < Consistency.CACHED and target_consistency._source_cached():
- raise StreamError(
- "Could not stage uncached source. For {} ".format(target.name)
- + "Use `--track` to track and "
- + "fetch the latest version of the "
- + "source."
- )
-
if not custom_dir:
directory = os.path.abspath(os.path.join(self._context.workspacedir, target.name))
if directory[-4:] == ".bst":
@@ -919,9 +907,8 @@ class Stream:
# Args:
# targets (list of str): The target elements to reset the workspace for
# soft (bool): Only set the workspace state to not prepared
- # track_first (bool): Whether to also track the sources first
#
- def workspace_reset(self, targets, *, soft, track_first):
+ def workspace_reset(self, targets, *, soft):
elements = self._load(targets, selection=PipelineSelection.REDIRECT)
@@ -1242,10 +1229,7 @@ class Stream:
# A convenience method for loading element lists
#
# If `targets` is not empty used project configuration will be
- # fully loaded. If `targets` is empty, tracking will still be
- # resolved for elements in `track_targets`, but no build pipeline
- # will be resolved. This is behavior is import for track() to
- # not trigger full loading of project configuration.
+ # fully loaded.
#
# Args:
# targets (list of str): Main targets to load
@@ -1259,7 +1243,6 @@ class Stream:
#
# Returns:
# (list of Element): The primary element selection
- # (list of Element): The tracking element selection
#
def _load(
self,
@@ -1327,7 +1310,6 @@ class Stream:
#
# Args:
# queue (Queue): Queue to add to the pipeline
- # track (bool): Whether this is the tracking queue
#
def _add_queue(self, queue):
self.queues.append(queue)
@@ -1338,7 +1320,7 @@ class Stream:
#
# Args:
# plan (list of Element): The list of elements to be enqueued
- # queue (Queue): The target queue, defaults to the first non-track queue
+ # queue (Queue): The target queue, defaults to the first queue
#
def _enqueue_plan(self, plan, *, queue=None):
queue = queue or self.queues[0]
@@ -1387,7 +1369,6 @@ class Stream:
#
# Args:
# elements (list of Element): Elements to fetch
- # track_elements (list of Element): Elements to track
# fetch_original (Bool): Whether to fetch original unstaged
#
def _fetch(self, elements, *, fetch_original=False):
diff --git a/src/buildstream/plugins/elements/junction.py b/src/buildstream/plugins/elements/junction.py
index 42b9ef08e..f0fcdcdfd 100644
--- a/src/buildstream/plugins/elements/junction.py
+++ b/src/buildstream/plugins/elements/junction.py
@@ -96,18 +96,9 @@ depend on a junction element itself.
.. note::
- BuildStream does not implicitly track junction elements. This means
- that if we were to invoke: `bst build --track-all ELEMENT` on an element
- which uses a junction element, the ref of the junction element
- will not automatically be updated if a more recent version exists.
-
- Therefore, if you require the most up-to-date version of a subproject,
- you must explicitly track the junction element by invoking:
- `bst source track JUNCTION_ELEMENT`.
-
- Furthermore, elements within the subproject are also not tracked by default.
- For this, we must specify the `--track-cross-junctions` option. This option
- must be preceeded by `--track ELEMENT` or `--track-all`.
+ Elements within the subproject are not tracked by default when running
+ `bst source track`. You must specify `--cross-junctions` to the track
+ command to explicitly do it.
Sources
diff --git a/src/buildstream/testing/_sourcetests/workspace.py b/src/buildstream/testing/_sourcetests/workspace.py
index 34e2247ea..3520a8cc4 100644
--- a/src/buildstream/testing/_sourcetests/workspace.py
+++ b/src/buildstream/testing/_sourcetests/workspace.py
@@ -49,7 +49,7 @@ class WorkspaceCreator:
self.workspace_cmd = os.path.join(self.project_path, "workspace_cmd")
- def create_workspace_element(self, kind, track, suffix="", workspace_dir=None, element_attrs=None):
+ def create_workspace_element(self, kind, suffix="", workspace_dir=None, element_attrs=None):
element_name = "workspace-test-{}{}.bst".format(kind, suffix)
element_path = os.path.join(self.project_path, "elements")
if not workspace_dir:
@@ -61,8 +61,6 @@ class WorkspaceCreator:
# the bin files, and then collect the initial ref.
repo = create_repo(kind, str(self.tmpdir))
ref = repo.create(self.bin_files_path)
- if track:
- ref = None
# Write out our test target
element = {"kind": "import", "sources": [repo.source_config(ref=ref)]}
@@ -71,7 +69,7 @@ class WorkspaceCreator:
_yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
return element_name, element_path, workspace_dir
- def create_workspace_elements(self, kinds, track, suffixs=None, workspace_dir_usr=None, element_attrs=None):
+ def create_workspace_elements(self, kinds, suffixs=None, workspace_dir_usr=None, element_attrs=None):
element_tuples = []
@@ -83,29 +81,25 @@ class WorkspaceCreator:
for suffix, kind in zip(suffixs, kinds):
element_name, _, workspace_dir = self.create_workspace_element(
- kind, track, suffix, workspace_dir_usr, element_attrs
+ kind, suffix, workspace_dir_usr, element_attrs
)
element_tuples.append((element_name, workspace_dir))
- # Assert that there is no reference, a track & fetch is needed
+ # Assert that there is no reference, a fetch is needed
states = self.cli.get_element_states(self.project_path, [e for e, _ in element_tuples])
- if track:
- assert not any(states[e] != "no reference" for e, _ in element_tuples)
- else:
- assert not any(states[e] != "fetch needed" for e, _ in element_tuples)
+ assert not any(states[e] != "fetch needed" for e, _ in element_tuples)
return element_tuples
- def open_workspaces(self, kinds, track, suffixs=None, workspace_dir=None, element_attrs=None, no_checkout=False):
+ def open_workspaces(self, kinds, suffixs=None, workspace_dir=None, element_attrs=None, no_checkout=False):
- element_tuples = self.create_workspace_elements(kinds, track, suffixs, workspace_dir, element_attrs)
+ element_tuples = self.create_workspace_elements(kinds, suffixs, workspace_dir, element_attrs)
os.makedirs(self.workspace_cmd, exist_ok=True)
# Now open the workspace, this should have the effect of automatically
- # tracking & fetching the source from the repo.
+ # fetching the source from the repo.
args = ["workspace", "open"]
- if track:
- args.append("--track")
+
if no_checkout:
args.append("--no-checkout")
if workspace_dir is not None:
@@ -136,7 +130,6 @@ def open_workspace(
tmpdir,
datafiles,
kind,
- track,
suffix="",
workspace_dir=None,
project_path=None,
@@ -144,7 +137,7 @@ def open_workspace(
no_checkout=False,
):
workspace_object = WorkspaceCreator(cli, tmpdir, datafiles, project_path)
- workspaces = workspace_object.open_workspaces((kind,), track, (suffix,), workspace_dir, element_attrs, no_checkout)
+ workspaces = workspace_object.open_workspaces((kind,), (suffix,), workspace_dir, element_attrs, no_checkout)
assert len(workspaces) == 1
element_name, workspace = workspaces[0]
return element_name, workspace_object.project_path, workspace
@@ -152,4 +145,4 @@ def open_workspace(
@pytest.mark.datafiles(DATA_DIR)
def test_open(cli, tmpdir, datafiles, kind):
- open_workspace(cli, tmpdir, datafiles, kind, False)
+ open_workspace(cli, tmpdir, datafiles, kind)