Unify the project dependency walks in App and pkg_relations() #118
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260922-unify-dep-walks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, andpkg_relations()has walked the same edges with its own queue for the relation queries. NowApp.walk_project_deps()is the single walk: the former helper, generalized withcheck_installed,excludeandrecurseparameters, andpkg_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 andpkg_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.__get_project_refs()public aswalk_project_deps(). Name changed because it sounds less awkwardcheck_installedapplies the installed-package check that skips the dependencies of an installed run package and fails on an unmet dependencyexcludenames specs that are neither traversed nor appendedrecurse = Falsestops the walk at the starting specApp.read_dep_edges(), because the other call site does the same thingcmds.projects.lib.pkg_relations(): Use walk_project_deps()
pkg_relations()walks the[pkg.<rel>.jw]edges with its own queue, duplicating the walk thatApp.walk_project_deps()extracted fromApp.__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. Thedont_expand_version_macroscondition 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-conflictsand theskip-excluded,names-onlyanddebianvariants 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>