diff --git a/dvc/command/ls/__init__.py b/dvc/command/ls/__init__.py index 31da618d8..6bcc88c2b 100644 --- a/dvc/command/ls/__init__.py +++ b/dvc/command/ls/__init__.py @@ -31,7 +31,7 @@ class CmdList(CmdBaseNoRepo): self.args.path, rev=self.args.rev, recursive=self.args.recursive, - outs_only=self.args.outs_only, + dvc_only=self.args.dvc_only, ) if entries: entries = _prettify(entries, sys.stdout.isatty()) @@ -62,7 +62,7 @@ def add_parser(subparsers, parent_parser): help="Recursively list files.", ) list_parser.add_argument( - "--outs-only", action="store_true", help="Show only DVC outputs." + "--dvc-only", action="store_true", help="Show only DVC outputs." ) list_parser.add_argument( "--rev", diff --git a/dvc/command/remove.py b/dvc/command/remove.py index 855180912..ab3a963a9 100644 --- a/dvc/command/remove.py +++ b/dvc/command/remove.py @@ -9,7 +9,7 @@ logger = logging.getLogger(__name__) class CmdRemove(CmdBase): - def _is_outs_only(self, target): + def _is_dvc_only(self, target): if not self.args.purge: return True @@ -31,8 +31,8 @@ class CmdRemove(CmdBase): def run(self): for target in self.args.targets: try: - outs_only = self._is_outs_only(target) - self.repo.remove(target, outs_only=outs_only) + dvc_only = self._is_dvc_only(target) + self.repo.remove(target, dvc_only=dvc_only) except DvcException: logger.exception(f"failed to remove '{target}'") return 1 diff --git a/dvc/exceptions.py b/dvc/exceptions.py index c9cce4879..0a62f9437 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -294,19 +294,15 @@ class PathMissingError(DvcException): "The path '{}' does not exist in the target repository '{}'" " neither as a DVC output nor as a Git-tracked file." ) - default_msg_output_only = ( + default_msg_dvc_only = ( "The path '{}' does not exist in the target repository '{}'" " as an DVC output." ) - def __init__(self, path, repo, output_only=False): - msg = ( - self.default_msg - if not output_only - else self.default_msg_output_only - ) + def __init__(self, path, repo, dvc_only=False): + msg = self.default_msg if not dvc_only else self.default_msg_dvc_only super().__init__(msg.format(path, repo)) - self.output_only = output_only + self.dvc_only = dvc_only class RemoteCacheRequiredError(DvcException): diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index 98f48a158..3fc0abce3 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -4,7 +4,7 @@ from dvc.path_info import PathInfo @staticmethod def ls( - url, path=None, rev=None, recursive=None, outs_only=False, + url, path=None, rev=None, recursive=None, dvc_only=False, ): """Methods for getting files and outputs for the repo. @@ -13,7 +13,7 @@ def ls( path (str, optional): relative path into the repo rev (str, optional): SHA commit, branch or tag name recursive (bool, optional): recursively walk the repo - outs_only (bool, optional): show only DVC-artifacts + dvc_only (bool, optional): show only DVC-artifacts Returns: list of `entry` @@ -40,13 +40,13 @@ def ls( ret = _ls(repo, path_info, recursive, True) nondvc = {} - if not outs_only: + if not dvc_only: nondvc = _ls(repo, path_info, recursive, False) ret.update(nondvc) if path and not ret: - raise PathMissingError(path, repo, output_only=outs_only) + raise PathMissingError(path, repo, dvc_only=dvc_only) ret_list = [] for path, info in ret.items(): diff --git a/dvc/repo/remove.py b/dvc/repo/remove.py index 8fccbf1bd..5c1f1023c 100644 --- a/dvc/repo/remove.py +++ b/dvc/repo/remove.py @@ -7,7 +7,7 @@ logger = logging.getLogger(__name__) @locked -def remove(self, target, outs_only=False): +def remove(self, target, dvc_only=False): from ..dvcfile import Dvcfile path, name = parse_target(target) @@ -16,7 +16,7 @@ def remove(self, target, outs_only=False): for stage in stages: stage.remove_outs(force=True) - if not outs_only: + if not dvc_only: dvcfile.remove() return stages diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 77ecf8c6a..061b13ebd 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -31,7 +31,7 @@ _dvc_import='-o --out --rev' _dvc_import_url='-f --file' _dvc_init='--no-scm -f --force' _dvc_install='' -_dvc_list='-R --recursive --outs-only --rev' +_dvc_list='-R --recursive --dvc-only --rev' _dvc_list_COMPGEN=_dvc_compgen_files _dvc_lock='' _dvc_lock_COMPGEN=_dvc_compgen_DVCFiles diff --git a/scripts/completion/dvc.zsh b/scripts/completion/dvc.zsh index 51a920a7d..7a12f1d35 100644 --- a/scripts/completion/dvc.zsh +++ b/scripts/completion/dvc.zsh @@ -170,7 +170,7 @@ _dvc_lock=( _dvc_list=( "--rev[Git revision (e.g. branch, tag, SHA)]:Revision:" {-R,--recursive}"[Recursively add each file under the directory.]" - "--outs-only[Only outputs DVC-outs.]" + "--dvc-only[Only outputs DVC-outs.]" "1:URL:" "2:Path:" ) diff --git a/tests/func/test_gc.py b/tests/func/test_gc.py index 4ed886290..5815b06e9 100644 --- a/tests/func/test_gc.py +++ b/tests/func/test_gc.py @@ -68,7 +68,7 @@ class TestGCBranchesTags(TestDvcGit): self.dvc.scm.tag("v1.0") self.dvc.scm.checkout("test", create_new=True) - self.dvc.remove(stages[0].relpath, outs_only=True) + self.dvc.remove(stages[0].relpath, dvc_only=True) with open(fname, "w+") as fobj: fobj.write("test") stages = self.dvc.add(fname) @@ -77,7 +77,7 @@ class TestGCBranchesTags(TestDvcGit): self.dvc.scm.commit("test") self.dvc.scm.checkout("master") - self.dvc.remove(stages[0].relpath, outs_only=True) + self.dvc.remove(stages[0].relpath, dvc_only=True) with open(fname, "w+") as fobj: fobj.write("trash") stages = self.dvc.add(fname) @@ -85,7 +85,7 @@ class TestGCBranchesTags(TestDvcGit): self.dvc.scm.add([".gitignore", stages[0].relpath]) self.dvc.scm.commit("trash") - self.dvc.remove(stages[0].relpath, outs_only=True) + self.dvc.remove(stages[0].relpath, dvc_only=True) with open(fname, "w+") as fobj: fobj.write("master") stages = self.dvc.add(fname) diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py index aa8383cdd..63d56b244 100644 --- a/tests/func/test_ls.py +++ b/tests/func/test_ls.py @@ -123,11 +123,11 @@ def test_ls_repo_recursive(tmp_dir, dvc, scm): ) -def test_ls_repo_outs_only_recursive(tmp_dir, dvc, scm): +def test_ls_repo_dvc_only_recursive(tmp_dir, dvc, scm): tmp_dir.scm_gen(FS_STRUCTURE, commit="init") tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") - files = Repo.ls(os.fspath(tmp_dir), recursive=True, outs_only=True) + files = Repo.ls(os.fspath(tmp_dir), recursive=True, dvc_only=True) match_files( files, ( @@ -156,13 +156,13 @@ def test_ls_repo_with_path_dir(tmp_dir, dvc, scm): ) -def test_ls_repo_with_path_dir_outs_only_empty(tmp_dir, dvc, scm): +def test_ls_repo_with_path_dir_dvc_only_empty(tmp_dir, dvc, scm): tmp_dir.scm_gen(FS_STRUCTURE, commit="init") tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") tmp_dir.scm_gen({"folder/.keep": "content"}, commit="add .keep") with pytest.raises(PathMissingError): - Repo.ls(os.fspath(tmp_dir), path="folder", outs_only=True) + Repo.ls(os.fspath(tmp_dir), path="folder", dvc_only=True) def test_ls_repo_with_path_subdir(tmp_dir, dvc, scm): @@ -182,21 +182,21 @@ def test_ls_repo_with_path_subdir(tmp_dir, dvc, scm): ) -def test_ls_repo_with_path_subdir_outs_only(tmp_dir, dvc, scm): +def test_ls_repo_with_path_subdir_dvc_only(tmp_dir, dvc, scm): tmp_dir.scm_gen(FS_STRUCTURE, commit="init") tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") path = os.path.join("data", "subcontent") - files = Repo.ls(os.fspath(tmp_dir), path, outs_only=True) + files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True) match_files(files, ((("data.xml",), True), (("statistics",), False),)) -def test_ls_repo_with_path_subdir_outs_only_recursive(tmp_dir, dvc, scm): +def test_ls_repo_with_path_subdir_dvc_only_recursive(tmp_dir, dvc, scm): tmp_dir.scm_gen(FS_STRUCTURE, commit="init") tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") path = os.path.join("data", "subcontent") - files = Repo.ls(os.fspath(tmp_dir), path, outs_only=True, recursive=True) + files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True, recursive=True) match_files( files, ((("data.xml",), True), (("statistics", "data.csv"), True),) ) @@ -226,10 +226,10 @@ def test_ls_repo_with_missed_path(tmp_dir, dvc, scm): with pytest.raises(PathMissingError) as exc_info: Repo.ls(os.fspath(tmp_dir), path="missed_path") - assert not exc_info.value.output_only + assert not exc_info.value.dvc_only -def test_ls_repo_with_missed_path_outs_only(tmp_dir, dvc, scm): +def test_ls_repo_with_missed_path_dvc_only(tmp_dir, dvc, scm): tmp_dir.scm_gen(FS_STRUCTURE, commit="init") tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc") @@ -238,9 +238,9 @@ def test_ls_repo_with_missed_path_outs_only(tmp_dir, dvc, scm): os.fspath(tmp_dir), path="missed_path", recursive=True, - outs_only=True, + dvc_only=True, ) - assert exc_info.value.output_only + assert exc_info.value.dvc_only def test_ls_repo_with_removed_dvc_dir(tmp_dir, dvc, scm): @@ -440,5 +440,5 @@ def test_ls_shows_pipeline_tracked_outs(tmp_dir, dvc, scm, run_copy): dvc.scm.add([PIPELINE_FILE, PIPELINE_LOCK]) dvc.scm.commit("add pipeline stage") - files = Repo.ls(os.curdir, outs_only=True) + files = Repo.ls(os.curdir, dvc_only=True) match_files(files, ((("bar",), True),)) diff --git a/tests/func/test_remove.py b/tests/func/test_remove.py index d65713a47..a6944609f 100644 --- a/tests/func/test_remove.py +++ b/tests/func/test_remove.py @@ -17,7 +17,7 @@ class TestRemove(TestDvc): self.assertEqual(len(stages), 1) stage = stages[0] self.assertTrue(stage is not None) - (stage_removed,) = self.dvc.remove(stage.path, outs_only=True) + (stage_removed,) = self.dvc.remove(stage.path, dvc_only=True) self.assertIsInstance(stage_removed, Stage) self.assertEqual(stage.path, stage_removed.path) diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index 319af0dbe..76af434d4 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -971,7 +971,7 @@ class TestReproExternalBase(SingleStageRun, TestDvc): self.dvc.gc(workspace=True) self.assertEqual(self.dvc.status(), {}) - self.dvc.remove(cmd_stage.path, outs_only=True) + self.dvc.remove(cmd_stage.path, dvc_only=True) self.assertNotEqual(self.dvc.status([cmd_stage.addressing]), {}) self.dvc.checkout([cmd_stage.path], force=True) @@ -1223,7 +1223,7 @@ class TestReproExternalHTTP(TestReproExternalBase): self.assertTrue(os.path.exists(run_output)) # Pull - self.dvc.remove(import_stage.path, outs_only=True) + self.dvc.remove(import_stage.path, dvc_only=True) self.assertFalse(os.path.exists(import_output)) shutil.move(self.local_cache, cache_id) diff --git a/tests/unit/command/ls/test_ls.py b/tests/unit/command/ls/test_ls.py index ed6908e8e..3b7b4b409 100644 --- a/tests/unit/command/ls/test_ls.py +++ b/tests/unit/command/ls/test_ls.py @@ -17,7 +17,7 @@ def test_list(mocker): url = "local_dir" m = _test_cli(mocker, url) m.assert_called_once_with( - url, None, recursive=False, rev=None, outs_only=False + url, None, recursive=False, rev=None, dvc_only=False ) @@ -25,7 +25,7 @@ def test_list_recursive(mocker): url = "local_dir" m = _test_cli(mocker, url, "-R") m.assert_called_once_with( - url, None, recursive=True, rev=None, outs_only=False + url, None, recursive=True, rev=None, dvc_only=False ) @@ -33,7 +33,7 @@ def test_list_git_ssh_rev(mocker): url = "git@github.com:repo" m = _test_cli(mocker, url, "--rev", "123") m.assert_called_once_with( - url, None, recursive=False, rev="123", outs_only=False + url, None, recursive=False, rev="123", dvc_only=False ) @@ -42,13 +42,13 @@ def test_list_targets(mocker): target = "subdir" m = _test_cli(mocker, url, target) m.assert_called_once_with( - url, target, recursive=False, rev=None, outs_only=False + url, target, recursive=False, rev=None, dvc_only=False ) def test_list_outputs_only(mocker): url = "local_dir" - m = _test_cli(mocker, url, None, "--outs-only") + m = _test_cli(mocker, url, None, "--dvc-only") m.assert_called_once_with( - url, None, recursive=False, rev=None, outs_only=True + url, None, recursive=False, rev=None, dvc_only=True )