diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py index e6fd674db..54902330f 100644 --- a/dvc/utils/fs.py +++ b/dvc/utils/fs.py @@ -75,22 +75,3 @@ def contains_symlink_up_to(path, base_path): if os.path.dirname(path) == path: return False return contains_symlink_up_to(os.path.dirname(path), base_path) - - -def get_parent_dirs_up_to(wdir, root_dir): - - assert os.path.isabs(wdir) - assert os.path.isabs(root_dir) - - wdir = os.path.normpath(wdir) - root_dir = os.path.normpath(root_dir) - if root_dir not in wdir: - return [] - - dirs = [] - dirs.append(wdir) - while wdir != root_dir: - wdir = os.path.dirname(wdir) - dirs.append(wdir) - - return dirs diff --git a/tests/unit/utils/test_fs.py b/tests/unit/utils/test_fs.py index 438a9c705..2cf460037 100644 --- a/tests/unit/utils/test_fs.py +++ b/tests/unit/utils/test_fs.py @@ -14,7 +14,6 @@ from dvc.utils.fs import BasePathNotInCheckedPathException from dvc.utils.fs import contains_symlink_up_to from dvc.utils.fs import get_inode from dvc.utils.fs import get_mtime_and_size -from dvc.utils.fs import get_parent_dirs_up_to from tests.basic_env import TestDir from tests.utils import spy @@ -103,49 +102,6 @@ class TestContainsLink(TestCase): ) -@pytest.mark.parametrize( - "path1, path2", - [ - ( - os.path.join("non", "abs", "path"), - os.path.join(os.sep, "full", "path"), - ), - ( - os.path.join(os.sep, "full", "path"), - os.path.join("non", "abs", "path"), - ), - ], -) -def test_get_parent_dirs_up_to_should_raise_on_no_absolute(path1, path2): - with pytest.raises(AssertionError): - get_parent_dirs_up_to(path1, path2) - - -@pytest.mark.parametrize( - "path1, path2, expected_dirs", - [ - ( - os.path.join(os.sep, "non", "matching", "path"), - os.path.join(os.sep, "other", "path"), - [], - ), - ( - os.path.join(os.sep, "some", "long", "path"), - os.path.join(os.sep, "some"), - [ - os.path.join(os.sep, "some"), - os.path.join(os.sep, "some", "long"), - os.path.join(os.sep, "some", "long", "path"), - ], - ), - ], -) -def test_get_parent_dirs_up_to(path1, path2, expected_dirs): - result = get_parent_dirs_up_to(path1, path2) - - assert set(result) == set(expected_dirs) - - @pytest.mark.skipif(os.name != "nt", reason="Windows specific") def test_relpath_windows_different_drives(): path1 = os.path.join("A:", os.sep, "some", "path")