summaryrefslogtreecommitdiff
path: root/src/buildstream/_pipeline.py
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2019-07-05 14:23:45 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-09 16:54:37 +0000
commit478d7889ef8ffa927f7ba412bd5dd374032c381d (patch)
tree18dcd2c38f5f804224223bdc0bce403c69176a5b /src/buildstream/_pipeline.py
parentfcce77761d118fb96a07afa32ae578fb7015a1ad (diff)
downloadbuildstream-478d7889ef8ffa927f7ba412bd5dd374032c381d.tar.gz
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`
Diffstat (limited to 'src/buildstream/_pipeline.py')
-rw-r--r--src/buildstream/_pipeline.py16
1 files changed, 16 insertions, 0 deletions
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,