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

Feature/message alias overridden #3456

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
12 changes: 8 additions & 4 deletions conans/client/graph/graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _load_deps(self, node, down_reqs, dep_graph, public_deps, down_ref, down_opt
param down_ref: ConanFileReference of who is depending on current node for this expansion
"""
# basic node configuration
new_reqs, new_options = self._config_node(node, down_reqs, down_ref, down_options)
new_reqs, new_options = self._config_node(node, down_reqs, down_ref, down_options, aliased)

self._resolve_deps(node, aliased, update, remote_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If _config_node performs the alias substitution, then it is no longer needed in _resolve_deps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is necessary, because _resolve_deps needs to check for alias AFTER the range has been resolved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the work done in _config_node does not require version ranges to be already resolved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, this applies to normal requires that are aliased.
However, you are right, I need to review this, maybe could be improved, it is complicated the deps resolution...
Please wait until I can check it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried a few things, and tests are broken. Leaving it as-is.


Expand Down Expand Up @@ -141,7 +141,7 @@ def _recurse(self, closure, new_reqs, new_options):
return True
return False

def _config_node(self, node, down_reqs, down_ref, down_options):
def _config_node(self, node, down_reqs, down_ref, down_options, aliased):
""" update settings and option in the current ConanFile, computing actual
requirement values, cause they can be overridden by downstream requires
param settings: dict of settings values => {"os": "windows"}
Expand Down Expand Up @@ -188,8 +188,12 @@ def _config_node(self, node, down_reqs, down_ref, down_options):
conanfile.requirements()

new_options = conanfile.options.deps_package_values
new_down_reqs = conanfile.requires.update(down_reqs, self._output, conanref,
down_ref)
if aliased:
for req in conanfile.requires.values():
req.conan_reference = aliased.get(req.conan_reference,
req.conan_reference)
new_down_reqs = conanfile.requires.update(down_reqs, self._output,
conanref, down_ref)
except ConanExceptionInUserConanfileMethod:
raise
except ConanException as e:
Expand Down
25 changes: 25 additions & 0 deletions conans/test/integration/alias_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@

class ConanAliasTest(unittest.TestCase):

def alias_overriden_test(self):
# https://github.com/conan-io/conan/issues/3353
client = TestClient()
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
pass
"""
client.save({"conanfile.py": conanfile})
client.run("export . PkgA/0.1@user/testing")
client.run("alias PkgA/latest@user/testing PkgA/0.1@user/testing")
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
requires = "PkgA/latest@user/testing"
"""
client.save({"conanfile.py": conanfile})
client.run("export . PkgB/0.1@user/testing")
client.run("alias PkgB/latest@user/testing PkgB/0.1@user/testing")
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
requires = "PkgA/latest@user/testing", "PkgB/latest@user/testing"
"""
client.save({"conanfile.py": conanfile})
client.run("info .")
self.assertNotIn("overridden", client.out)

def test_alias_different_name(self):
client = TestClient()
error = client.run("alias myalias/1.0@user/channel lib/1.0@user/channel",
Expand Down