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

conan search <pattern> --revisions with cache Issue/5472 #5537

Merged
merged 35 commits into from Jul 29, 2019
Merged
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
16d2c6d
Added required = True to subparsers in order to print error message i…
czoido Apr 4, 2019
ca0d13f
Merge remote-tracking branch 'upstream/develop' into develop
czoido Apr 10, 2019
6ab6126
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Apr 10, 2019
028e495
sync
czoido Apr 10, 2019
4b014e0
basic concurrent upload at reference level with futures
czoido Apr 10, 2019
de66b1d
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Apr 15, 2019
bfa9366
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Apr 21, 2019
f9e3ee0
revert changes
czoido Apr 21, 2019
4a8f6ce
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Apr 23, 2019
052b6ff
add line
czoido Apr 23, 2019
2f999d2
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jun 4, 2019
618c4a5
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jun 10, 2019
3cd895b
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jun 24, 2019
2b2f7c2
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jun 25, 2019
20fee8b
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jun 26, 2019
b0adf57
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 1, 2019
9989584
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 2, 2019
4a21d2d
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 3, 2019
9c30bf2
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 8, 2019
d6f2e65
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 17, 2019
38868d9
Merge branch 'develop' of https://github.com/conan-io/conan into develop
czoido Jul 25, 2019
4c17b73
include revision in string if present
czoido Jul 25, 2019
30388e7
pass revisions argument
czoido Jul 25, 2019
42903f8
minor changes
czoido Jul 25, 2019
dd1f897
error when --revisions and --remote with pattern
czoido Jul 26, 2019
4723ed5
behaviour has changed, had to modify test
czoido Jul 26, 2019
96d3096
revert most of changes
czoido Jul 26, 2019
870b69b
move implementation to command.py
czoido Jul 26, 2019
d20a843
raise exception when no valid filter
czoido Jul 26, 2019
e4ab962
change order
czoido Jul 26, 2019
28bc2f8
add some tests
czoido Jul 26, 2019
cf549b5
restore method
lasote Jul 29, 2019
1130d28
Merge remote-tracking branch 'origin/develop' into issue/5472
lasote Jul 29, 2019
77f070b
Refactor
lasote Jul 29, 2019
25009a6
Try refactor
lasote Jul 29, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1212,17 +1212,36 @@ def search(self, *args):
else:
info = self._conan.get_package_revisions(repr(pref), remote_name=args.remote)

if not info:
if not ref:
msg = "With --revision, specify a reference (e.g {ref}) or a package " \
"reference with " \
"recipe revision (e.g {ref}#3453453453:d50a0d523d98c15bb147b18f" \
"a7d203887c38be8b)".format(ref=_REFERENCE_EXAMPLE)
raise ConanException(msg)
info = self._conan.get_recipe_revisions(repr(ref),
remote_name=args.remote)
self._outputer.print_revisions(ref, info, remote_name=args.remote)
return
if not ref and not info:
exc_msg = "With --revision, specify a reference (e.g {ref}) a valid pattern " \
"or a package reference with " \
"recipe revision (e.g {ref}#3453453453:d50a0d523d98c15bb147b18f" \
"a7d203887c38be8b)".format(ref=_REFERENCE_EXAMPLE)
if args.remote:
raise ConanException(exc_msg)
else:
info = self._conan.search_recipes(args.pattern_or_reference,
remote_name=args.remote,
case_sensitive=args.case_sensitive)
if info["results"]:

This comment has been minimized.

Copy link
@lasote

lasote Jul 29, 2019

Contributor

This feels hacky too

for remote_info in info["results"]:
for conan_item in remote_info["items"]:
reference = conan_item["recipe"]["id"]
ref = ConanFileReference.loads(reference)
rev = self._conan.get_recipe_revisions(repr(ref),
remote_name=args.remote,
check_rev_time=False)
self._outputer.print_revisions(ref, rev, remote_name=args.remote)
else:
raise ConanException(exc_msg)

return
else:
if not info:
info = self._conan.get_recipe_revisions(repr(ref),
remote_name=args.remote)
self._outputer.print_revisions(ref, info, remote_name=args.remote)
return

if ref:
info = self._conan.search_packages(repr(ref), query=args.query,
@@ -1093,7 +1093,7 @@ def get_remote_by_name(self, remote_name):
return self._cache.registry.load_remotes()[remote_name]

@api_method
def get_recipe_revisions(self, reference, remote_name=None):
def get_recipe_revisions(self, reference, remote_name=None, check_rev_time=True):

This comment has been minimized.

Copy link
@lasote

lasote Jul 29, 2019

Contributor

I think we shouldn't change this method. That check_rev_time is a patch.

if 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"
@@ -1111,20 +1111,21 @@ def get_recipe_revisions(self, reference, remote_name=None):
e.print_rev = True
raise e

# Check the time in the associated remote if any
remote_name = layout.load_metadata().recipe.remote
remote = self._cache.registry.load_remotes()[remote_name] if remote_name else None
rev_time = None
if remote:
try:
revisions = self._remote_manager.get_recipe_revisions(ref, remote)
except RecipeNotFoundException:
pass
except (NoRestV2Available, NotFoundException):
rev_time = None
else:
tmp = {r["revision"]: r["time"] for r in revisions}
rev_time = tmp.get(rev)
if check_rev_time:
# Check the time in the associated remote if any
remote_name = layout.load_metadata().recipe.remote
remote = self._cache.registry.load_remotes()[remote_name] if remote_name else None
if remote:
try:
revisions = self._remote_manager.get_recipe_revisions(ref, remote)
except RecipeNotFoundException:
pass
except (NoRestV2Available, NotFoundException):
rev_time = None
else:
tmp = {r["revision"]: r["time"] for r in revisions}
rev_time = tmp.get(rev)

return [{"revision": rev, "time": rev_time}]
else:
@@ -1194,6 +1194,10 @@ class Test(ConanFile):
client.run("search lib/1.0@user/testing --revisions")
self.assertIn("bd761686d5c57b31f4cd85fd0329751f (No time)", client.out)

# test that the pattern search with --revisions enabled works
client.run("search li* --revisions")
self.assertIn("bd761686d5c57b31f4cd85fd0329751f (No time)", client.out)

This comment has been minimized.

Copy link
@lasote

lasote Jul 29, 2019

Contributor

Is it lib/1.0@user/testing#bd761686d5c57b31f4cd85fd0329751f (No time)? In that case assert the whole line because it is confusing what is bd761686d5c57b31f4cd85fd0329751f


with patch.object(RevisionList, '_now', return_value=the_time):
client.run("upload lib/1.0@user/testing -c")

@@ -1348,6 +1352,10 @@ class Test(ConanFile):

# IN REMOTE

# Search with pattern and remotes
client.run("search * --revisions -r default", assert_error=True)
self.assertIn("ERROR: With --revision, specify a reference", client.out)

# Search not found in remote
client.run("search missing/1.0@conan/stable --revisions -r default", assert_error=True)
self.assertIn("ERROR: Recipe not found: 'missing/1.0@conan/stable'", client.out)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.