summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/_frontend/app.py8
-rw-r--r--src/buildstream/_frontend/widget.py14
-rw-r--r--src/buildstream/_scheduler/jobs/job.py2
-rw-r--r--src/buildstream/_scheduler/queues/queue.py4
-rw-r--r--src/buildstream/element.py15
-rw-r--r--src/buildstream/types.py18
6 files changed, 39 insertions, 22 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index 59bc3513b..2f4235733 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -454,13 +454,13 @@ class App:
def shell_prompt(self, element):
element_name = element._get_full_name()
-
- _, key, dim = element._get_display_key()
+ display_key = element._get_display_key()
if self.colors:
+ dim_key = not display_key.strict
prompt = (
self._format_profile.fmt("[")
- + self._content_profile.fmt(key, dim=dim)
+ + self._content_profile.fmt(display_key.brief, dim=dim_key)
+ self._format_profile.fmt("@")
+ self._content_profile.fmt(element_name)
+ self._format_profile.fmt(":")
@@ -469,7 +469,7 @@ class App:
+ " "
)
else:
- prompt = "[{}@{}:${{PWD}}]$ ".format(key, element_name)
+ prompt = "[{}@{}:${{PWD}}]$ ".format(display_key.brief, element_name)
return prompt
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index 65f74d475..7b2ff2688 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -209,15 +209,16 @@ class CacheKey(Widget):
if message.element_name is None:
return " " * self._key_length
- missing = False
+ dim = False
key = " " * self._key_length
if message.element_key:
- _, key, missing = message.element_key
+ key = message.element_key.brief
+ dim = not message.element_key.strict
if message.message_type in ERROR_MESSAGES:
text = self._err_profile.fmt(key)
else:
- text = self.content_profile.fmt(key, dim=missing)
+ text = self.content_profile.fmt(key, dim=dim)
return text
@@ -340,11 +341,12 @@ class LogLine(Widget):
for element in dependencies:
line = format_
- full_key, cache_key, dim_keys = element._get_display_key()
+ key = element._get_display_key()
+ dim_keys = not key.strict
line = p.fmt_subst(line, "name", element._get_full_name(), fg="blue", bold=True)
- line = p.fmt_subst(line, "key", cache_key, fg="yellow", dim=dim_keys)
- line = p.fmt_subst(line, "full-key", full_key, fg="yellow", dim=dim_keys)
+ line = p.fmt_subst(line, "key", key.brief, fg="yellow", dim=dim_keys)
+ line = p.fmt_subst(line, "full-key", key.full, fg="yellow", dim=dim_keys)
try:
if not element._has_all_sources_resolved():
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index c8ff853ed..388fe0f5d 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -289,7 +289,7 @@ class Job:
# key for for the issuing message (if an element is related to the Job).
#
# Args:
- # element_key (tuple): The element_key tuple to be supplied to the Message() constructor
+ # element_key (_DisplayKey): The element_key tuple to be supplied to the Message() constructor
#
def set_message_element_key(self, element_key):
self._message_element_key = element_key
diff --git a/src/buildstream/_scheduler/queues/queue.py b/src/buildstream/_scheduler/queues/queue.py
index 9e444b393..f5aa2ca4c 100644
--- a/src/buildstream/_scheduler/queues/queue.py
+++ b/src/buildstream/_scheduler/queues/queue.py
@@ -356,9 +356,9 @@ class Queue:
def _element_log_path(self, element):
project = element._get_project()
- key = element._get_display_key()[1]
+ key = element._get_display_key()
action = self.action_name.lower()
- logfile = "{key}-{action}".format(key=key, action=action)
+ logfile = "{key}-{action}".format(key=key.brief, action=action)
return os.path.join(project.name, element.normal_name, logfile)
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index c9480d4fc..9d108c878 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -102,7 +102,7 @@ from .plugin import Plugin
from .sandbox import SandboxFlags, SandboxCommandError
from .sandbox._config import SandboxConfig
from .sandbox._sandboxremote import SandboxRemote
-from .types import _Scope, _CacheBuildTrees, _KeyStrength, OverlapAction
+from .types import _Scope, _CacheBuildTrees, _KeyStrength, OverlapAction, _DisplayKey
from ._artifact import Artifact
from ._elementproxy import ElementProxy
from ._elementsources import ElementSources
@@ -1398,15 +1398,13 @@ class Element(Plugin):
# Returns cache keys for display purposes
#
# Returns:
- # (str): A full hex digest cache key for this Element
- # (str): An abbreviated hex digest cache key for this Element
- # (bool): True if key should be shown as dim, False otherwise
+ # (_DisplayKey): The display key
#
# Question marks are returned if information for the cache key is missing.
#
def _get_display_key(self):
context = self._get_context()
- dim_key = True
+ strict = False
cache_key = self._get_cache_key()
@@ -1415,10 +1413,10 @@ class Element(Plugin):
elif cache_key == self.__strict_cache_key:
# Strong cache key used in this session matches cache key
# that would be used in strict build mode
- dim_key = False
+ strict = True
length = min(len(cache_key), context.log_key_length)
- return (cache_key, cache_key[0:length], dim_key)
+ return _DisplayKey(cache_key, cache_key[0:length], strict)
# _get_brief_display_key()
#
@@ -1430,8 +1428,7 @@ class Element(Plugin):
# Question marks are returned if information for the cache key is missing.
#
def _get_brief_display_key(self):
- _, display_key, _ = self._get_display_key()
- return display_key
+ return self._get_display_key().brief
# _tracking_done():
#
diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index a5cf7afb8..67383f86a 100644
--- a/src/buildstream/types.py
+++ b/src/buildstream/types.py
@@ -208,6 +208,24 @@ class _KeyStrength(FastEnum):
WEAK = 2
+# _DisplayKey():
+#
+# The components of a cache key which need to be displayed
+#
+# This is a part of Message() so it needs to be a simple serializable object.
+#
+# Args:
+# full: A full hex digest cache key for an Element
+# brief: An abbreviated hex digest cache key for an Element
+# strict: Whether the key matches the key which would be used in strict mode
+#
+class _DisplayKey:
+ def __init__(self, full: str, brief: str, strict: bool):
+ self.full = full # type: str
+ self.brief = brief # type: str
+ self.strict = strict # type: bool
+
+
# _SchedulerErrorAction()
#
# Actions the scheduler can take on error