tree: check that repo.tree is CleanTree when using walk_files

This commit is contained in:
pawel
2019-12-30 14:19:43 +01:00
parent e225601031
commit e1eab9405c
3 changed files with 13 additions and 3 deletions
+5
View File
@@ -13,6 +13,7 @@ from dvc.config import Config
from dvc.exceptions import DownloadError
from dvc.exceptions import DvcException
from dvc.exceptions import UploadError
from dvc.ignore import CleanTree
from dvc.path_info import PathInfo
from dvc.progress import Tqdm
from dvc.remote.base import RemoteBASE
@@ -138,6 +139,8 @@ class RemoteLOCAL(RemoteBASE):
return os.path.getsize(fspath_py35(path_info))
def walk_files(self, path_info):
assert isinstance(self.repo.tree, CleanTree)
for fname in self.repo.tree.walk_files(path_info):
yield PathInfo(fname)
@@ -427,6 +430,8 @@ class RemoteLOCAL(RemoteBASE):
os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE)
def _unprotect_dir(self, path):
assert isinstance(self.repo.tree, CleanTree)
for fname in self.repo.tree.walk_files(path):
RemoteLOCAL._unprotect_file(fname)
+4
View File
@@ -35,6 +35,10 @@ def get_inode(path):
def get_mtime_and_size(path, tree):
from dvc.ignore import CleanTree
assert isinstance(tree, CleanTree)
if os.path.isdir(fspath_py35(path)):
size = 0
files_mtimes = {}
+4 -3
View File
@@ -116,10 +116,11 @@ def test_ignore_on_branch(tmp_dir, scm, dvc):
assert _files_set(".", dvc.tree) == {"./foo", "./bar"}
tree = CleanTree(scm.get_tree("branch"))
files_on_branch = {
f for r, ds, fs in tree.walk(tree.tree_root) for f in fs
assert _files_set(".", tree) == {
os.path.join(tree.tree_root, DvcIgnore.DVCIGNORE_FILE),
os.path.join(tree.tree_root, "bar"),
}
assert "foo" not in files_on_branch
def _files_set(root, tree):