Skip to content

Commit

Permalink
JobStatusDisplay: show length of merge-wait queue
Browse files Browse the repository at this point in the history
Since FEATURES=merge-wait is now the default, the length of the
merge-wait queue becomes more relevant. Hence show it as part of
portage's job status display.

Signed-off-by: Florian Schmaus <[email protected]>
Closes: #1347
Signed-off-by: James Le Cuirot <[email protected]>
  • Loading branch information
Flowdalic authored and chewi committed Aug 2, 2024
1 parent f99eb91 commit 6d1ee2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Features:
* emerge: Make bare --root-deps option install build-time dependencies to ROOT
as well as / for all EAPIs rather than instead of / for EAPI 6 and below
(bug #435066).
* Show length of merge-wait queue as part of the status display

Bug fixes:
* ebuild: Handle Bash 5.2's change in behavior which enables the shopt
Expand Down
10 changes: 9 additions & 1 deletion lib/_emerge/JobStatusDisplay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2020 Gentoo Authors
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

import io
Expand Down Expand Up @@ -38,6 +38,7 @@ def __init__(self, quiet=False, xterm_titles=True):
object.__setattr__(self, "quiet", quiet)
object.__setattr__(self, "xterm_titles", xterm_titles)
object.__setattr__(self, "maxval", 0)
object.__setattr__(self, "merge_wait", 0)
object.__setattr__(self, "merges", 0)
object.__setattr__(self, "_changed", False)
object.__setattr__(self, "_displayed", False)
Expand Down Expand Up @@ -262,6 +263,13 @@ def _display_status(self):
f.pop_style()
f.add_literal_data(" failed")

if self.merge_wait:
f.add_literal_data(", ")
f.push_style(number_style)
f.add_literal_data(f"{self.merge_wait}")
f.pop_style()
f.add_literal_data(" merge wait")

padding = self._jobs_column_width - len(plain_output.getvalue())
if padding > 0:
f.add_literal_data(padding * " ")
Expand Down
3 changes: 3 additions & 0 deletions lib/_emerge/Scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ def _build_exit(self, build):
self._deallocate_config(build.settings)
self._jobs -= 1
self._status_display.running = self._jobs
self._status_display.merge_wait = len(self._merge_wait_queue)
self._schedule()

def _extract_exit(self, build):
Expand Down Expand Up @@ -1836,6 +1837,8 @@ def _schedule_tasks(self):
if task.is_system_pkg:
break

self._status_display.merge_wait = len(self._merge_wait_queue)

if self._schedule_tasks_imp():
state_change += 1

Expand Down

0 comments on commit 6d1ee2c

Please sign in to comment.