Repository: conan-io/conan

Issue:
[revisions] Error on search recipe revisions in remote
When revisions are NOT enabled in the Conan Client and a remote search or recipe revisions is done, Conan errors with:

```
$ conan search wiringpi/2.46@conan/stable --revisions -r conan-virtual
ERROR: The remote doesn't support revisions. [Remote: conan-virtual]
```
H
owever, the remote DOES support revisions and the fault is in the client not having them activated and thus not being able to talk via V2 with the remote.

There should be raise early in the code saying that revisions are not enabled, then, if the user enables revisions and finally the remote DOES NOT support revisions, the message ``ERROR: The remote doesn't support revisions. [Remote: conan-virtual]`` would be valid

----------------------------------------

There could be also the option of disabling the ``--revisions`` flag even for local search when revisions are not enabled


Discussion:

Resolving patch:
diff --git a/conans/client/command.py b/conans/client/command.py
--- a/conans/client/command.py
+++ b/conans/client/command.py
@@ -1017,8 +1017,15 @@ def search(self, *args):
         parser.add_argument("-rev", "--revisions", default=False, action='store_true',
                             help='Get a list of revisions for a reference or a '
                                  'package reference.')
+
         args = parser.parse_args(*args)
 
+        if args.revisions and not self._cache.config.revisions_enabled:
+            raise ConanException("The client doesn't have the revisions feature enabled."
+                                 " Enable this feature setting to '1' the environment variable"
+                                 " 'CONAN_REVISIONS_ENABLED' or the config value"
+                                 " 'general.revisions_enabled' in your conan.conf file")
+
         if args.table and args.json:
             raise ConanException("'--table' argument cannot be used together with '--json'")
 


Test patch:
diff --git a/conans/test/functional/command/search_test.py b/conans/test/functional/command/search_test.py
--- a/conans/test/functional/command/search_test.py
+++ b/conans/test/functional/command/search_test.py
@@ -1079,20 +1079,6 @@ def initial_search_without_registry_test(self):
         self.assertIn("WARN: Remotes registry file missing, creating default one", client.out)
         self.assertIn("There are no packages matching the 'my_pkg' pattern", client.out)
 
-    def test_usage_of_list_revisions(self):
-        client = TestClient()
-        conanfile = dedent("""
-                    from conans import ConanFile
-                    class Test(ConanFile):
-                        pass
-                    """)
-        client.save({"conanfile.py": conanfile})
-        client.run("create . lib/1.0@conan/stable")
-        client.run("search lib/1.0@conan/stable --revisions")
-        self.assertIn("Revisions for 'lib/1.0@conan/stable':", client.out)
-        # FIXME: Should be "0" when no revisions are enabled?
-        self.assertIn("bd761686d5c57b31f4cd85fd0329751f", client.out)
-
 
 @unittest.skipIf(get_env("TESTING_REVISIONS_ENABLED", False), "No sense with revs")
 class SearchOutdatedTest(unittest.TestCase):
@@ -1121,6 +1107,11 @@ class Test(ConanFile):
             self.assertIn("os: Windows", client.user_io.out)
             self.assertNotIn("os: Linux", client.user_io.out)
 
+    def test_exception_client_without_revs(self):
+        client = TestClient()
+        client.run("search whatever --revisions", assert_error=True)
+        self.assertIn("ERROR: The client doesn't have the revisions feature enabled", client.out)
+
 
 @unittest.skipUnless(get_env("TESTING_REVISIONS_ENABLED", False),
                      "set TESTING_REVISIONS_ENABLED=1")
@@ -1359,6 +1350,7 @@ def test_invalid_references_test(self):
                    assert_error=True)
         self.assertIn("Cannot list the revisions of a specific package revision", client.out)
 
+
 class SearchRemoteAllTestCase(unittest.TestCase):
     def setUp(self):
         """ Create a remote called 'all' with some recipe in it """