Repository: conan-io/conan

Issue:
Unnecessary and deranging override message when using alias packages
In a situation with 3 packages CA, CB and CC where CB requires CA (via an alias) and CC requires CB and CA also via aliases, when installing CC with a "conan install ..." conan reports a version override while actually the alias is pointing to exaclty the version of the package that conan says overrides the alias:

CB/0.0.2@user/testing requirement CA/ALIAS@user/testing overriden by CC/0.0.3@user/testing to CA/0.0.1@user/testing


To help us debug your issue please `explain:`

- [X] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [X] I've specified the Conan version, operating system version and any tool that can be relevant.
- [X] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:

[conan_alias_message_demo.tar.gz](https://github.com/conan-io/conan/files/2290174/conan_alias_message_demo.tar.gz)
This was observed with conan version 1.3.3 on Windows and on Linux.
I attach a tar file with an example that reproduces this behavior. Untar the file and in the directory execute 'create_all_packages.sh'. After that issue 'conan install CC/ALIAS@user/testing' or 'conan install CC/0.0.3@user/testing' and the above message will appear.
Sorry, reopened ... wrong mouse click.
Could you check with Conan 1.6? Important changes have been introduced in the graph processing since 1.3.

Thanks
Checked with conan 1.6.1: exact same behavior as 1.3.3.
This needs to be looked into. The thing is that when that message is output, it might not have all the information in the graph.

Resolving patch:
diff --git a/conans/client/graph/graph_builder.py b/conans/client/graph/graph_builder.py
--- a/conans/client/graph/graph_builder.py
+++ b/conans/client/graph/graph_builder.py
@@ -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)
 
@@ -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"}
@@ -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:


Test patch:
diff --git a/conans/test/integration/alias_test.py b/conans/test/integration/alias_test.py
--- a/conans/test/integration/alias_test.py
+++ b/conans/test/integration/alias_test.py
@@ -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",