Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue when overrides happen in diamonds #13631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conans/client/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def propagate_closing_loop(self, require, prev_node):
# List to avoid mutating the dict
for transitive in list(prev_node.transitive_deps.values()):
# TODO: possibly optimize in a bulk propagate
if transitive.require.override:
continue
prev_node.propagate_downstream(transitive.require, transitive.node, self)

def propagate_downstream(self, require, node, src_node=None):
Expand Down
61 changes: 61 additions & 0 deletions conans/test/integration/graph/core/graph_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,38 @@ def test_private_conflict(self):
self._check_node(libc, "libc/0.1#123", deps=[], dependents=[libd])
self._check_node(liba1, "liba/0.1#123", dependents=[libb])

def test_diamond_transitive_private(self):
# https://github.com/conan-io/conan/issues/13630
# libc0.1 ----------> liba0.1 --(private) -> zlib/1.0
# \-> --(libb---->/

self.recipe_cache("zlib/0.1")
self.recipe_conanfile("liba/0.1", GenConanfile("liba", "0.1")
.with_requirement("zlib/0.1", visible=False))
self.recipe_cache("libb/0.1", ["liba/0.1"])
self.recipe_cache("libc/0.1", ["liba/0.1", "libb/0.1"])
consumer = self.consumer_conanfile(GenConanfile("libc", "0.1")
.with_requires("liba/0.1", "libb/0.1"))
deps_graph = self.build_consumer(consumer)

self.assertEqual(4, len(deps_graph.nodes))
libc = deps_graph.root
liba = libc.dependencies[0].dst
libb = libc.dependencies[1].dst
liba1 = libb.dependencies[0].dst
zlib = liba.dependencies[0].dst

assert liba is liba1
# TODO: No Revision??? Because of consumer?
self._check_node(libc, "libc/0.1", deps=[liba, libb])
self._check_node(libb, "libb/0.1#123", deps=[liba], dependents=[libc])
self._check_node(liba, "liba/0.1#123", dependents=[libb, libc], deps=[zlib])
self._check_node(zlib, "zlib/0.1#123", dependents=[liba])

_check_transitive(libb, [(liba, True, True, False, False)])
_check_transitive(libc, [(libb, True, True, False, False),
(liba, True, True, False, False)])


class TestDiamondMultiple(GraphManagerTest):

Expand Down Expand Up @@ -1898,6 +1930,35 @@ def test_override_solve_upstream_conflict(self):
self._check_node(libb, "libb/0.1#123", deps=[liba], dependents=[libc])
self._check_node(liba, "liba/0.3#123", dependents=[libb, libc])

def test_override_not_used(self):
# https://github.com/conan-io/conan/issues/13630
# libc0.1 ----------> liba0.1 --(override) -> zlib/1.0
# \-> --(libb---->/

self.recipe_conanfile("liba/0.1", GenConanfile("liba", "0.1")
.with_requirement("zlib/0.1", override=True))
self.recipe_cache("libb/0.1", ["liba/0.1"])
self.recipe_cache("libc/0.1", ["liba/0.1", "libb/0.1"])
consumer = self.consumer_conanfile(GenConanfile("libc", "0.1")
.with_requires("liba/0.1", "libb/0.1"))
deps_graph = self.build_consumer(consumer)

self.assertEqual(3, len(deps_graph.nodes))
libc = deps_graph.root
liba = libc.dependencies[0].dst
libb = libc.dependencies[1].dst
liba1 = libb.dependencies[0].dst

assert liba is liba1
# TODO: No Revision??? Because of consumer?
self._check_node(libc, "libc/0.1", deps=[liba, libb])
self._check_node(libb, "libb/0.1#123", deps=[liba], dependents=[libc])
self._check_node(liba, "liba/0.1#123", dependents=[libb, libc])

_check_transitive(libb, [(liba, True, True, False, False)])
_check_transitive(libc, [(libb, True, True, False, False),
(liba, True, True, False, False)])


class PackageIDDeductions(GraphManagerTest):

Expand Down