Unify the project dependency walks in App and pkg_relations() #118

Merged
Jan Lindemann merged 2 commits from jan/feature/20260922-unify-dep-walks into master 2026-09-22 05:47:35 +02:00 AGit

This PR makes one of the two independent walks of the [pkg.*.jw] dependency edges the only one. App.get_project_refs() has walked them with a private recursive helper for the build closures, and pkg_relations() has walked the same edges with its own queue for the relation queries. Now App.walk_project_deps() is the single walk: the former helper, generalized with check_installed, exclude and recurse parameters, and pkg_relations() computes its closure with it, keeping only its constraint rendering. The two walkers can no longer drift apart.

App.walk_project_deps() / read_dep_edges(): Add methods

App.get_project_refs() uses __get_project_refs() to walk the [pkg.*.jw] sections and pkg_relations() walks the same edges with its own implementation. In an attempt to unify the walks, this commit tries to make the first walk implementation so generally useful that it can be used by the second.

  • Make __get_project_refs() public as walk_project_deps(). Name changed because it sounds less awkward
  • Add three parameters needed from the other call site:
    • check_installed applies the installed-package check that skips the dependencies of an installed run package and fails on an unmet dependency
    • exclude names specs that are neither traversed nor appended
    • recurse = False stops the walk at the starting spec
  • Wrap the per-project dependency reading into App.read_dep_edges(), because the other call site does the same thing

cmds.projects.lib.pkg_relations(): Use walk_project_deps()

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.

This PR makes one of the two independent walks of the `[pkg.*.jw]` dependency edges the only one. `App.get_project_refs()` has walked them with a private recursive helper for the build closures, and `pkg_relations()` has walked the same edges with its own queue for the relation queries. Now `App.walk_project_deps()` is the single walk: the former helper, generalized with `check_installed`, `exclude` and `recurse` parameters, and `pkg_relations()` computes its closure with it, keeping only its constraint rendering. The two walkers can no longer drift apart. #### App.walk_project_deps() / read_dep_edges(): Add methods `App.get_project_refs()` uses `__get_project_refs()` to walk the `[pkg.*.jw]` sections and `pkg_relations()` walks the same edges with its own implementation. In an attempt to unify the walks, this commit tries to make the first walk implementation so generally useful that it can be used by the second. - Make `__get_project_refs()` public as `walk_project_deps()`. Name changed because it sounds less awkward - Add three parameters needed from the other call site: - `check_installed` applies the installed-package check that skips the dependencies of an installed run package and fails on an unmet dependency - `exclude` names specs that are neither traversed nor appended - `recurse = False` stops the walk at the starting spec - Wrap the per-project dependency reading into `App.read_dep_edges()`, because the other call site does the same thing #### cmds.projects.lib.pkg_relations(): Use walk_project_deps() `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.
App.get_project_refs() uses __get_project_refs() to walk the [pkg.*.jw]
sections and pkg_relations() walks the same edges with its own
implementation. In an attempt to unify the walks, this commit tries to make
the first walk implementation so generally useful that it can be used by
the second.

- Make __get_project_refs() public as walk_project_deps(). Name changed
  because it sounds less awkward
- Add three parameters needed from the other call site:
  - check_installed applies the installed-package check that skips the
    dependencies of an installed run package and fails on an unmet
    dependency
  - exclude names specs that are neither traversed nor appended
  - recurse = False stops the walk at the starting spec
- Wrap the per-project dependency reading into App.read_dep_edges(),
  because the other call site does the same thing

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1
Signed-off-by: Jan Lindemann <jan@janware.com>
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
5eccef847d
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>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-09-22 05:37:46 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!118
No description provided.