cmds.projects.lib.pkg_relations(): Use walk_project_deps()
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m59s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m46s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m5s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m32s
CI / Packaging test (push) Successful in 0s

pkg_relations() walks the [pkg.<rel>.jw] edges with its own queue,
duplicating the walk that App.walk_project_deps() extracted from
App.__get_project_refs() in the previous commit. Port it onto the shared
walk: for each flavour, the walk computes the closure of the seed packages
(with the installed-package check off, the ignore set as exclude, and
recursion per the recursive flag), and the function then emits the
constraint strings of the edges of the visited projects.

The relation sets are unchanged. The order of recursive output follows the
walk (postorder) instead of the old breadth-first order; non-recursive
callers, such as the spec generation and the PREREQ_* queries, print
byte-identical output. The dont_expand_version_macros condition now tests
membership in the visited set instead of the old queue, which only matters
when the flag is passed manually.

Verified over all projects of the dev tree: pkg-requires, pkg-recommends,
pkg-conflicts and the skip-excluded, names-only and debian variants are
byte-identical for the non-recursive forms and set-identical for the
recursive ones.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-09-21 19:09:14 +02:00
commit 5eccef847d
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -52,18 +52,26 @@ def pkg_relations(
ret: list[str] = [] ret: list[str] = []
for flavour in flavours: # build / release / run / devel for flavour in flavours: # build / release / run / devel
cur_pkgs = seed_pkgs.copy() closure: list[str] = []
visited_pkgs: set[str] = set() visited: set[str] = set()
while len(cur_pkgs): for seed in seed_pkgs:
cur_pkg = cur_pkgs.pop(0) app.walk_project_deps(
if cur_pkg in visited_pkgs or cur_pkg in ignore: closure,
continue visited,
seed,
['pkg.' + rel_type + '.jw'],
flavour,
add_self = True,
scope = Scope.Subtree,
names_only = True,
check_installed = False,
exclude = ignore,
recurse = recursive,
)
for cur_pkg in closure:
for subsec in subsections: for subsec in subsections:
section = 'pkg.' + rel_type + '.' + subsec section = 'pkg.' + rel_type + '.' + subsec
visited_pkgs.add(cur_pkg) for deps_spec in app.read_dep_edges(cur_pkg, [section], flavour):
deps_spec = app.get_value(cur_pkg, section, flavour)
if not deps_spec:
continue
for dep in Dependency.parse_deps_spec( for dep in Dependency.parse_deps_spec(
deps_spec, deps_spec,
lookup_version = app.get_version, lookup_version = app.get_version,
@ -73,13 +81,10 @@ def pkg_relations(
if dep_name in ignore or dep.full_name in ignore: if dep_name in ignore or dep.full_name in ignore:
continue continue
if subsec == 'jw': if subsec == 'jw':
if (recursive and dep_name not in visited_pkgs
and dep_name not in cur_pkgs):
cur_pkgs.append(dep_name)
if hide_jw_pkg and dep_name == 'jw-pkg': if hide_jw_pkg and dep_name == 'jw-pkg':
continue continue
expand_version_macros = subsec == 'jw' expand_version_macros = subsec == 'jw'
if dont_expand_version_macros and dep_name in cur_pkgs: if dont_expand_version_macros and dep_name in visited:
expand_version_macros = False expand_version_macros = False
if hide_self and dep_name in seed_pkgs: if hide_self and dep_name in seed_pkgs:
continue continue