From a7db279fb09829c4d8521f265bb1a0f0957e9264 Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Tue, 25 Aug 2026 15:45:48 +0200 Subject: [PATCH] conandeps: spell out each branch's path on indirect nodes in the tree Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01EYNdaGDrpaqDyT8QtrTQbM --- README.md | 9 +++++---- conandeps.py | 2 ++ tests/test_conandeps.py | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 224d566..0a8f715 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,10 @@ Dependency hierarchy MyProject/conanfile.py |-- MyDepA/1.0 -| `-- boost/1.8 +| `-- boost/1.8 [MyDepA -> boost] `-- MyDepB/1.0 - `-- Zigma/1.0 [MISSING: RelWithDebInfo] - `-- boost/1.8 [overrides boost/1.7 (implicit by your conanfile)] + `-- Zigma/1.0 [MyDepB -> Zigma; MISSING: RelWithDebInfo] + `-- boost/1.8 [MyDepB -> Zigma -> boost; overrides boost/1.7 (implicit by your conanfile)] ``` On a terminal the tables are coloured (green = on the remote, red = missing, @@ -135,7 +135,8 @@ package required by several others gets one line per parent (boost above is pulled in by both MyDepA and Zigma), shortest path first. Rows are sorted direct-first, then by path, so a branch's transitive dependencies stay together; the dependency hierarchy section at the end shows the same -information as a tree. +information as a tree, and every indirect node there also spells out the +path of its branch so deep indentation never has to be counted. * a remote name (e.g. `myremote`) – the remote has a binary for the package_id your diff --git a/conandeps.py b/conandeps.py index a8de228..ab6158e 100755 --- a/conandeps.py +++ b/conandeps.py @@ -450,6 +450,8 @@ def _tree_lines(report: Report) -> List[str]: lines.append(prefix + branch + name + " (not in graph)") return tags = [] + if seen: # indirect: spell out this branch's path so indentation need not be counted + tags.append(" -> ".join(seen + (name,))) if dep.build_require: tags.append("build-require") ov = edge_overrides.get((parent, name)) diff --git a/tests/test_conandeps.py b/tests/test_conandeps.py index dca9569..dcf79fe 100644 --- a/tests/test_conandeps.py +++ b/tests/test_conandeps.py @@ -337,6 +337,10 @@ def test_text_and_html_render(report, tmp_path): assert "package wanted forced to by kind" in text assert "libfoo/1.0 libbar/1.0 libbar/1.1 your conanfile explicit (override=True)" in text assert "overrides libbar/1.0 (explicit" in text # tree edge annotation + # Tree lines carry the full path of their branch; direct nodes do not. + tree = text.split("Dependency hierarchy")[1] + assert re.search(r"`-- libdeep/1\.0 \[libfoo -> libbar -> libdeep\]", tree) + assert re.search(r"\|-- libfoo/1\.0\n", tree) coloured = conandeps.render_text(report, color=True) assert "\033[1;31mMISSING\033[0m" in coloured and "\033[32mtest\033[0m" in coloured