From 478d7889ef8ffa927f7ba412bd5dd374032c381d Mon Sep 17 00:00:00 2001 From: Jonathan Maw Date: Fri, 5 Jul 2019 14:23:45 +0100 Subject: Pipeline: Add a helper for adding lists of elements together Lists of elements should never contain duplicate elements. This commit also uses the helper to calculate the list of elements when pulling missing elements in `bst shell` --- src/buildstream/_pipeline.py | 16 ++++++++++++++++ src/buildstream/_stream.py | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py index 4352df56c..440bd8bd3 100644 --- a/src/buildstream/_pipeline.py +++ b/src/buildstream/_pipeline.py @@ -319,6 +319,22 @@ class Pipeline(): if e not in subtract_set ] + # add_elements() + # + # Add to a list of elements all elements that are not already in it + # + # Args: + # elements (list of Element): The element list + # add (list of Element): List of elements to add + # + # Returns: + # (list): The original elements list, with elements in add that weren't + # already in it added. + def add_elements(self, elements, add): + ret = elements[:] + ret.extend(e for e in add if e not in ret) + return ret + # track_cross_junction_filter() # # Filters out elements which are across junction boundaries, diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 594da997e..fcd40c3b4 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -180,7 +180,8 @@ class Stream(): self._message(MessageType.INFO, "Attempting to fetch missing or incomplete artifacts") self._scheduler.clear_queues() self._add_queue(PullQueue(self._scheduler)) - self._enqueue_plan([element] + missing_deps) + plan = self._pipeline.add_elements([element], missing_deps) + self._enqueue_plan(plan) self._run() buildtree = False -- cgit v1.2.1