Repository: conan-io/conan

Issue:
Lockfiles of packages without user/channel have _
The lockfile contains:

```
"graph_lock": {
  "nodes": {
   "3e78db6e-de3d-11e9-bfb7-84fdd15e6b30": {
    "pref": "test4/0.1@_/_:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9", 
    "options": ""
   }
  }
 ```

Should it drop the user/channel with _? Should that be used exclusively for paths and folders?

Right now it seems there is no support for something that is able to dump ``PackageReference`` including the revisions but dropping None user/channel.




Discussion:
Yes. It should be dropped.

Resolving patch:
diff --git a/conans/client/graph/range_resolver.py b/conans/client/graph/range_resolver.py
--- a/conans/client/graph/range_resolver.py
+++ b/conans/client/graph/range_resolver.py
@@ -140,6 +140,9 @@ def resolve(self, require, base_conanref, update, remotes):
 
     def _resolve_local(self, search_ref, version_range):
         local_found = search_recipes(self._cache, search_ref)
+        local_found = [ref for ref in local_found
+                       if ref.user == search_ref.user and
+                       ref.channel == search_ref.channel]
         if local_found:
             return self._resolve_version(version_range, local_found)
 
diff --git a/conans/model/ref.py b/conans/model/ref.py
--- a/conans/model/ref.py
+++ b/conans/model/ref.py
@@ -210,8 +210,8 @@ def __str__(self):
 
     def __repr__(self):
         str_rev = "#%s" % self.revision if self.revision else ""
-        return "%s/%s@%s/%s%s" % (self.name, self.version, self.user or "_", self.channel or "_",
-                                  str_rev)
+        user_channel = "@%s/%s" % (self.user, self.channel) if self.user or self.channel else ""
+        return "%s/%s%s%s" % (self.name, self.version, user_channel, str_rev)
 
     def full_str(self):
         str_rev = "#%s" % self.revision if self.revision else ""
diff --git a/conans/search/search.py b/conans/search/search.py
--- a/conans/search/search.py
+++ b/conans/search/search.py
@@ -76,21 +76,17 @@ def _evaluate(prop_name, prop_value, conan_vars_info):
     conan_vars_info.serialize_min()
     """
 
-    def compatible_prop(setting_value, prop_value):
-        return (prop_value == setting_value) or (prop_value == "None" and setting_value is None)
+    def compatible_prop(setting_value, _prop_value):
+        return (_prop_value == setting_value) or (_prop_value == "None" and setting_value is None)
 
     info_settings = conan_vars_info.get("settings", [])
     info_options = conan_vars_info.get("options", [])
     properties = ["os", "os_build", "compiler", "arch", "arch_build", "build_type"]
 
-    def starts_with_common_settings(prop_name):
-        for setting in properties:
-            if prop_name.startswith(setting + '.'):
-                return True
-        return False
+    def starts_with_common_settings(_prop_name):
+        return any(_prop_name.startswith(setting + '.') for setting in properties)
 
-    if (prop_name in properties or
-            starts_with_common_settings(prop_name)):
+    if prop_name in properties or starts_with_common_settings(prop_name):
         return compatible_prop(info_settings.get(prop_name, None), prop_value)
     else:
         return compatible_prop(info_options.get(prop_name, None), prop_value)
@@ -104,8 +100,7 @@ def search_recipes(cache, pattern=None, ignorecase=True):
         pattern = translate(pattern)
         pattern = re.compile(pattern, re.IGNORECASE) if ignorecase else re.compile(pattern)
 
-    subdirs = list_folder_subdirs(basedir=cache.store, level=4)
-    refs = [ConanFileReference.load_dir_repr(folder) for folder in subdirs]
+    refs = cache.all_refs()
     refs.extend(cache.editable_packages.edited_refs.keys())
     if pattern:
         refs = [r for r in refs if _partial_match(pattern, repr(r))]


Test patch: