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

Use --confirm to not request confirmation when removing instead of --force #12636

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions conan/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def remove(conan_api: ConanAPI, parser, *args):
"""
parser.add_argument('reference', help="Recipe reference or package reference, can contain * as"
"wildcard at any reference field. e.g: lib/*")
parser.add_argument('-f', '--force', default=False, action='store_true',
parser.add_argument('-c', '--confirm', default=False, action='store_true',
help='Remove without requesting a confirmation')
parser.add_argument('-p', '--package-query', action=OnceArgument,
help="Remove all packages (empty) or provide a query: "
Expand All @@ -29,7 +29,7 @@ def remove(conan_api: ConanAPI, parser, *args):
remote = conan_api.remotes.get(args.remote) if args.remote else None

def confirmation(message):
return args.force or ui.request_boolean(message)
return args.confirm or ui.request_boolean(message)

only_recipe = ":" not in args.reference and not args.package_query
ref_pattern = SelectPattern(args.reference, rrev="*", prev="*")
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/command/test_install_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def deploy(graph, output_folder, **kwargs):
"main.cpp": gen_function_cpp(name="main", includes=["hello"], calls=["hello"])},
clean_first=True)
c.run("install . --deploy=deploy.py -of=mydeploy -g CMakeToolchain -g CMakeDeps")
c.run("remove * -f") # Make sure the cache is clean, no deps there
c.run("remove * -c") # Make sure the cache is clean, no deps there
cwd = c.current_folder.replace("\\", "/")
arch = c.get_default_host_profile().settings['arch']
deps = c.load(f"mydeploy/hello-release-{arch}-data.cmake")
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/configuration/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def _assert_env_variable_printed(self, name, value):

def test_info_with_profiles(self):

self.client.run("remove '*' -f")
self.client.run("remove '*' -c")
# Create a simple recipe to require
winreq_conanfile = '''
from conans.model.conan_file import ConanFile
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/graph_lock/lock_install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_install_recipes():
assert "pkgb/0.1@user/channel:cfd10f60aeaa00f5ca1f90b5fe97c3fe19e7ec23 - Cache" in client.out

client.run("upload * -c -r default")
client.run("remove * -f")
client.run("remove * -c")
client.run("lock install lock1.lock --recipes")

assert "pkga/0.1@user/channel:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Download" in client.out
Expand Down
42 changes: 21 additions & 21 deletions conans/test/functional/revisions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_install_binary_iterating_remotes_same_rrev(self):
the_time = time.time()
with patch.object(RevisionList, '_now', return_value=the_time):
self.c_v2.upload_all(self.ref, remote="default")
self.c_v2.run("remove {}#*:{} -f -r default".format(self.ref, pref.package_id))
self.c_v2.run("remove {}#*:{} -c -r default".format(self.ref, pref.package_id))
# Same RREV, different PREV
with environment_update({"MY_VAR": "2"}):
pref2 = self.c_v2.create(self.ref, conanfile=conanfile)
Expand Down Expand Up @@ -271,15 +271,15 @@ def test_remove_local_recipe(self):
# If I remove the ref, the revision is gone, of course
ref1 = client.export(self.ref)
ref1.revision = None
client.run("remove {} -f".format(repr(ref1)))
client.run("remove {} -c".format(repr(ref1)))
self.assertFalse(client.recipe_exists(self.ref))

# If I remove a ref with a wrong revision, the revision is not removed
ref1 = client.export(self.ref)
fakeref = copy.copy(ref1)
fakeref.revision = "fakerev"
full_ref = repr(fakeref)
client.run("remove {} -f".format(repr(fakeref)), assert_error=True)
client.run("remove {} -c".format(repr(fakeref)), assert_error=True)
self.assertIn(f"ERROR: Recipe revision '{full_ref}' not found", client.out)
self.assertTrue(client.recipe_exists(self.ref))

Expand All @@ -295,41 +295,41 @@ def test_remove_local_package(self):
pref1 = client.create(self.ref)
tmp = copy.copy(pref1.ref)
tmp.revision = None
client.run("remove {} -f".format(repr(tmp)))
client.run("remove {} -c".format(repr(tmp)))
self.assertFalse(client.package_exists(pref1))

# If I remove the ref with fake RREV, the packages are not removed
pref1 = client.create(self.ref)
fakeref = copy.copy(pref1.ref)
fakeref.revision = "fakerev"
str_ref = repr(fakeref)
client.run("remove {} -f".format(repr(fakeref)), assert_error=True)
client.run("remove {} -c".format(repr(fakeref)), assert_error=True)
self.assertTrue(client.package_exists(pref1))
self.assertIn("Recipe revision '{}' not found".format(str_ref), client.out)

# If I remove the ref with valid RREV, the packages are removed
pref1 = client.create(self.ref)
client.run("remove {} -f".format(repr(pref1.ref)))
client.run("remove {} -c".format(repr(pref1.ref)))
self.assertFalse(client.package_exists(pref1))

# If I remove the ref without RREV but specifying PREV it raises
pref1 = client.create(self.ref)
tmp = copy.copy(pref1.ref)
tmp.revision = None
command = "remove {}:{}#{} -f".format(repr(tmp), pref1.package_id, pref1.revision)
command = "remove {}:{}#{} -c".format(repr(tmp), pref1.package_id, pref1.revision)
client.run(command)
self.assertFalse(client.package_exists(pref1))

# A wrong PREV doesn't remove the PREV
pref1 = client.create(self.ref)
command = "remove {}:{}#fakeprev -f".format(repr(pref1.ref), pref1.package_id)
command = "remove {}:{}#fakeprev -c".format(repr(pref1.ref), pref1.package_id)
client.run(command, assert_error=True)
self.assertTrue(client.package_exists(pref1))
self.assertIn("ERROR: Package revision", client.out)

# Everything correct, removes the unique local package revision
pref1 = client.create(self.ref)
command = "remove {}:{}#{} -f".format(repr(pref1.ref), pref1.package_id, pref1.revision)
command = "remove {}:{}#{} -c".format(repr(pref1.ref), pref1.package_id, pref1.revision)
client.run(command)
self.assertFalse(client.package_exists(pref1))

Expand All @@ -348,7 +348,7 @@ def test_remove_remote_recipe(self):
remover_client = self.c_v2

# Remove ref without revision in a remote
remover_client.run("remove {} -f -r default".format(self.ref))
remover_client.run("remove {} -c -r default".format(self.ref))
self.assertFalse(self.server.recipe_exists(self.ref))
self.assertFalse(self.server.recipe_exists(pref1.ref))
self.assertFalse(self.server.recipe_exists(pref2.ref))
Expand All @@ -370,7 +370,7 @@ def test_remove_remote_recipe_revision(self):
remover_client = self.c_v2

# Remove ref without revision in a remote
command = "remove {} -f -r default".format(repr(pref1.ref))
command = "remove {} -c -r default".format(repr(pref1.ref))
remover_client.run(command)
self.assertFalse(self.server.recipe_exists(pref1.ref))
self.assertTrue(self.server.recipe_exists(pref2.ref))
Expand All @@ -393,7 +393,7 @@ def test_remove_remote_package(self):
remover_client = self.c_v2

# Remove pref without RREV in a remote
remover_client.run("remove {}#*:{} -f -r default".format(self.ref, pref2.package_id))
remover_client.run("remove {}#*:{} -c -r default".format(self.ref, pref2.package_id))
self.assertTrue(self.server.recipe_exists(pref1.ref))
self.assertTrue(self.server.recipe_exists(pref2.ref))
self.assertFalse(self.server.package_exists(pref1))
Expand Down Expand Up @@ -431,7 +431,7 @@ def test_remove_remote_package_revision(self):
remover_client = self.c_v2

# Remove PREV without RREV in a remote, the client has to fail
command = "remove {}:{}#{} -f -r default".format(self.ref, pref2.package_id, pref2.revision)
command = "remove {}:{}#{} -c -r default".format(self.ref, pref2.package_id, pref2.revision)
remover_client.run(command)

self.assertTrue(self.server.recipe_exists(pref1.ref))
Expand All @@ -442,7 +442,7 @@ def test_remove_remote_package_revision(self):
self.assertFalse(self.server.package_exists(pref2))

# Try to remove a missing revision
command = "remove {}:{}#fakerev -f -r default".format(repr(pref2.ref), pref2.package_id)
command = "remove {}:{}#fakerev -c -r default".format(repr(pref2.ref), pref2.package_id)
remover_client.run(command, assert_error=True)
fakeref = copy.copy(pref2)
fakeref.revision = "fakerev"
Expand Down Expand Up @@ -867,7 +867,7 @@ def test_rotation_deleting_recipe_revisions(self):
ref3.revision)

# Delete the latest from the server
self.c_v2.run("remove {} -r default -f".format(repr(ref3)))
self.c_v2.run("remove {} -r default -c".format(repr(ref3)))
revs = [r.revision for r in self.server.server_store.get_recipe_revisions_references(self.ref)]
self.assertEqual(revs, [ref2.revision, ref1.revision])
self.assertEqual(self.server.server_store.get_last_revision(self.ref).revision,
Expand Down Expand Up @@ -910,7 +910,7 @@ def test_rotation_deleting_package_revisions(self):
pref3.revision)

# Delete the latest from the server
self.c_v2.run("remove {}:{}#{} -r default -f".format(repr(pref3.ref),pref3.package_id,
self.c_v2.run("remove {}:{}#{} -r default -c".format(repr(pref3.ref),pref3.package_id,
pref3.revision))
revs = [r.revision
for r in self.server.server_store.get_package_revisions_references(pref)]
Expand All @@ -930,9 +930,9 @@ def test_deleting_all_rrevs(self):
ref3 = self.c_v2.export(self.ref, conanfile=GenConanfile().with_build_msg("I'm rev3"))
self.c_v2.upload_all(ref3)

self.c_v2.run("remove {} -r default -f".format(repr(ref1)))
self.c_v2.run("remove {} -r default -f".format(repr(ref2)))
self.c_v2.run("remove {} -r default -f".format(repr(ref3)))
self.c_v2.run("remove {} -r default -c".format(repr(ref1)))
self.c_v2.run("remove {} -r default -c".format(repr(ref2)))
self.c_v2.run("remove {} -r default -c".format(repr(ref3)))

self.assertRaises(RecipeNotFoundException,
self.server.server_store.get_recipe_revisions_references, self.ref)
Expand Down Expand Up @@ -960,7 +960,7 @@ def test_deleting_all_prevs(self):
self.c_v2.upload_all(self.ref)

# Delete the package revisions (all of them have the same ref#rev and id)
command = "remove {}:{}#{{}} -r default -f".format(pref3.ref.repr_notime(), pref3.package_id)
command = "remove {}:{}#{{}} -r default -c".format(pref3.ref.repr_notime(), pref3.package_id)
self.c_v2.run(command.format(pref3.revision))
self.c_v2.run(command.format(pref2.revision))
self.c_v2.run(command.format(pref1.revision))
Expand All @@ -984,7 +984,7 @@ def test_touching_other_server():
c.save({"conanfile.py": GenConanfile().with_settings("os")})
c.run("create . --name=pkg --version=0.1 --user=conan --channel=channel -s os=Windows")
c.run("upload * -c -r=remote1")
c.run("remove * -f")
c.run("remove * -c")

# This is OK, binary found
c.run("install --requires=pkg/0.1@conan/channel -r=remote1 -s os=Windows")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def build(self):
def test_transitive_binary_skipped(transitive_libraries):
c = transitive_libraries
# IMPORTANT: liba binary can be removed, no longer necessary
c.run("remove liba*:* -f")
c.run("remove liba*:* -c")

conanfile = textwrap.dedent("""\
from conan import ConanFile
Expand Down
8 changes: 4 additions & 4 deletions conans/test/functional/toolchains/cmake/test_shared_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_shared_cmake_toolchain():
client.save(pkg_cmake_app("app", "0.1", requires=["chat/0.1"]), clean_first=True)
client.run("create . -o chat/*:shared=True -o hello/*:shared=True")
client.run("upload * -c -r default")
client.run("remove * -f")
client.run("remove * -c")

client = TestClient(servers=client.servers)
client.run("install --requires=app/0.1@ -o chat*:shared=True -o hello/*:shared=True -g VirtualRunEnv")
Expand Down Expand Up @@ -96,7 +96,7 @@ def test(self):

# We try to remove the hello package and run again the executable from the test package,
# this time it should fail, it doesn't find the shared library
client.run("remove '*' -f")
client.run("remove '*' -c")
client.run_command(os.path.join(exe_folder, "example"), assert_error=True)
return client

Expand Down Expand Up @@ -181,7 +181,7 @@ def test(self):
""")
test_client_shared.save({"test_package/CMakeLists.txt": cmake, "test_package/conanfile.py": cf})
test_client_shared.run("create . -o hello*:shared=True")
test_client_shared.run("remove '*' -f")
test_client_shared.run("remove '*' -c")
exe_folder = os.path.join("test_package", "test_output", "bin")
test_client_shared.run_command(os.path.join(exe_folder, "test"))

Expand All @@ -199,7 +199,7 @@ def test_shared_same_dir_using_env_var_current_dir(test_client_shared):
exe_folder = os.path.join("test_package", "test_output", "build", "release")
rmdir(os.path.join(test_client_shared.current_folder, exe_folder))
test_client_shared.run("create . -o hello*:shared=True")
test_client_shared.run("remove '*' -f")
test_client_shared.run("remove '*' -c")
test_client_shared.current_folder = os.path.join(test_client_shared.current_folder, exe_folder)
test_client_shared.run_command("DYLD_LIBRARY_PATH=$(pwd) ./example")
test_client_shared.run_command("DYLD_LIBRARY_PATH=. ./example")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_autotools_relocatable_libs_darwin_downloaded():
client.run("new autotools_lib -d name=hello -d version=0.1")
client.run("create . -o hello/*:shared=True -tf=None")
client.run("upload hello/0.1 -c -r default")
client.run("remove * -f")
client.run("remove * -c")

conanfile = textwrap.dedent("""
from conan import ConanFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_build_mode_requires(self):
self.assertIn("tool/0.1@lasote/stable: Generated conaninfo.txt", client.out)

# now remove packages, ensure --build=missing also creates them
client.run('remove "*:*" -f')
client.run('remove "*:*" -c')
client.run("install . --profile ./profile.txt --build=missing")
self.assertIn("tool/0.1@lasote/stable: Generated conaninfo.txt", client.out)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test(self):
# IMPORTANT: The consumption via test_package allows specifying the type of requires
# in this case: None, as this is intended to be injected via profile [tool_requires]
# can be tested like that
c.run("remove * -f")
c.run("remove * -c")
c.save({"test_package/conanfile.py": test})

# Creating the NDK packages for Windows, Linux
Expand Down
34 changes: 17 additions & 17 deletions conans/test/integration/cache/cache2_update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_revision_fixed_version(self):
self.client2.assert_listed_require({"liba/1.0.0": "Cache"})
assert "liba/1.0.0: Already installed!" in self.client2.out

self.client.run("remove * -f")
self.client.run("remove * -c")

# | CLIENT | CLIENT2 | SERVER0 | SERVER1 | SERVER2 |
# |-------------|------------|------------|-----------|------------|
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_revision_fixed_version(self):
# to the date in server0 and associate that remote but not install anything

# we create a newer revision in client2
self.client2.run("remove * -f")
self.client2.run("remove * -c")
self.client2.save({"conanfile.py": GenConanfile("liba", "1.0.0").with_build_msg("REV2")})
self.client2.run("create .")

Expand All @@ -144,10 +144,10 @@ def test_revision_fixed_version(self):
assert self.client.cache.get_recipe_timestamp(latest_rrev) == self.server_times["server2"]

# we create a newer revision in client
self.client.run("remove * -f")
self.client.run("remove * -c")
self.client.save({"conanfile.py": GenConanfile("liba", "1.0.0").with_build_msg("REV2")})
self.client.run("create .")
self.client.run(f"remove {latest_rrev.repr_notime()} -f -r server2")
self.client.run(f"remove {latest_rrev.repr_notime()} -c -r server2")

# | CLIENT | CLIENT2 | SERVER0 | SERVER1 | SERVER2 |
# |-------------|------------|------------|-----------|------------|
Expand Down Expand Up @@ -213,11 +213,11 @@ def test_revision_fixed_version(self):
self.client.assert_listed_require({"liba/1.0.0": "Cache"})
assert "liba/1.0.0: Already installed!" in self.client.out

self.client.run("remove * -f")
self.client.run("remove * -c")

self.client.run("remove '*' -f -r server0")
self.client.run("remove '*' -f -r server1")
self.client.run("remove '*' -f -r server2")
self.client.run("remove '*' -c -r server0")
self.client.run("remove '*' -c -r server1")
self.client.run("remove '*' -c -r server2")

# create new older revisions in servers
self.client.save({"conanfile.py": GenConanfile("liba", "1.0.0").with_build_msg("REV4")})
Expand All @@ -227,7 +227,7 @@ def test_revision_fixed_version(self):

self._upload_ref_to_all_servers("liba/1.0.0", self.client)

self.client.run("remove * -f")
self.client.run("remove * -c")

# | CLIENT | CLIENT2 | SERVER0 | SERVER1 | SERVER2 |
# |-------------|------------|------------|-----------|------------|
Expand Down Expand Up @@ -280,10 +280,10 @@ def test_revision_fixed_version(self):
assert self.the_time == self.client.cache.get_recipe_timestamp(server_rrev)
self.client.assert_listed_require({"liba/1.0.0": "Cache (Updated date) (server2)"})

self.client.run("remove * -f")
self.client.run("remove '*' -f -r server0")
self.client.run("remove '*' -f -r server1")
self.client.run("remove '*' -f -r server2")
self.client.run("remove * -c")
self.client.run("remove '*' -c -r server0")
self.client.run("remove '*' -c -r server1")
self.client.run("remove '*' -c -r server2")

self.client.save({"conanfile.py": GenConanfile("liba", "1.0.0").with_build_msg("REV6")})
self.client.run("create .")
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_revision_fixed_version(self):
# | | REV0 (1000)| | | |
# | | | | | |

self.client.run("remove * -f")
self.client.run("remove * -c")

# | CLIENT | CLIENT2 | SERVER0 | SERVER1 | SERVER2 |
# |-------------|------------|------------|-----------|------------|
Expand Down Expand Up @@ -365,7 +365,7 @@ def test_version_ranges(self):
assert "liba/[>0.9.0]: liba/1.0.0" in self.client.out
assert "liba/1.0.0: Already installed!" in self.client.out

self.client.run("remove * -f")
self.client.run("remove * -c")

# | CLIENT | CLIENT2 | SERVER0 | SERVER1 | SERVER2 |
# |----------------|----------------|----------------|----------------|----------------|
Expand Down Expand Up @@ -417,8 +417,8 @@ def test_version_ranges(self):
# | | | | | |
# | | | | | |

self.client.run("remove * -f")
self.client2.run("remove * -f")
self.client.run("remove * -c")
self.client2.run("remove * -c")

# now we are uploading different revisions with different dates, but the same version
for minor in range(3):
Expand Down
Loading