-
Notifications
You must be signed in to change notification settings - Fork 1.2k
repo: move dvcignore from repo to tree #2974
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
Changes from all commits
956fec0
f4ee01c
aa613f9
cf2fac5
d8c0ae6
d8813dc
56ed535
cf2d349
e225601
e1eab94
691d771
1880656
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| 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 | ||
|
|
@@ -21,6 +22,7 @@ | |
| from dvc.remote.base import STATUS_MISSING | ||
| from dvc.remote.base import STATUS_NEW | ||
| from dvc.scheme import Schemes | ||
| from dvc.scm.tree import WorkingTree | ||
| from dvc.system import System | ||
| from dvc.utils import copyfile | ||
| from dvc.utils import file_md5 | ||
|
|
@@ -83,7 +85,7 @@ def supported(cls, config): | |
|
|
||
| def list_cache_paths(self): | ||
| assert self.path_info is not None | ||
| return walk_files(self.path_info, None) | ||
| return walk_files(self.path_info) | ||
|
|
||
| def get(self, md5): | ||
| if not md5: | ||
|
|
@@ -138,7 +140,11 @@ def getsize(path_info): | |
| return os.path.getsize(fspath_py35(path_info)) | ||
|
|
||
| def walk_files(self, path_info): | ||
| for fname in walk_files(path_info, self.repo.dvcignore): | ||
| assert isinstance(self.repo.tree, CleanTree) and isinstance( | ||
| self.repo.tree.tree, WorkingTree | ||
| ) | ||
|
|
||
| for fname in self.repo.tree.walk_files(path_info): | ||
|
||
| yield PathInfo(fname) | ||
|
|
||
| def get_file_checksum(self, path_info): | ||
|
|
@@ -427,7 +433,9 @@ def _unprotect_file(path): | |
| os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) | ||
|
|
||
| def _unprotect_dir(self, path): | ||
| for fname in walk_files(path, self.repo.dvcignore): | ||
| assert isinstance(self.repo.tree, CleanTree) | ||
|
||
|
|
||
| for fname in self.repo.tree.walk_files(path): | ||
|
||
| RemoteLOCAL._unprotect_file(fname) | ||
|
|
||
| def unprotect(self, path_info): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from funcy import group_by | ||
|
|
||
| from dvc.ignore import CleanTree | ||
| from dvc.scm.tree import WorkingTree | ||
|
|
||
|
|
||
|
|
@@ -34,7 +35,7 @@ def brancher( # noqa: E302 | |
|
|
||
| scm = self.scm | ||
|
|
||
| self.tree = WorkingTree(self.root_dir) | ||
| self.tree = CleanTree(WorkingTree(self.root_dir)) | ||
|
||
| yield "working tree" | ||
|
|
||
| if all_commits: | ||
|
|
@@ -58,7 +59,7 @@ def brancher( # noqa: E302 | |
| # code which might expect the tree on which exception was raised to | ||
| # stay in place. This behavior is a subject to change. | ||
| for sha, names in group_by(scm.resolve_rev, revs).items(): | ||
| self.tree = scm.get_tree(sha) | ||
| self.tree = CleanTree(scm.get_tree(sha)) | ||
| yield ", ".join(names) | ||
|
|
||
| self.tree = saved_tree | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -378,7 +378,7 @@ def save(self, path_info, checksum): | |
| assert os.path.exists(fspath_py35(path_info)) | ||
|
|
||
| actual_mtime, actual_size = get_mtime_and_size( | ||
|
||
| path_info, self.repo.dvcignore | ||
| path_info, self.repo.tree | ||
| ) | ||
| actual_inode = get_inode(path_info) | ||
|
|
||
|
|
@@ -410,9 +410,7 @@ def get(self, path_info): | |
| if not os.path.exists(path): | ||
| return None | ||
|
|
||
| actual_mtime, actual_size = get_mtime_and_size( | ||
| path, self.repo.dvcignore | ||
| ) | ||
| actual_mtime, actual_size = get_mtime_and_size(path, self.repo.tree) | ||
| actual_inode = get_inode(path) | ||
|
|
||
| existing_record = self.get_state_record_for_inode(actual_inode) | ||
|
|
@@ -439,7 +437,7 @@ def save_link(self, path_info): | |
| if not os.path.exists(path): | ||
| return | ||
|
|
||
| mtime, _ = get_mtime_and_size(path, self.repo.dvcignore) | ||
| mtime, _ = get_mtime_and_size(path, self.repo.tree) | ||
| inode = get_inode(path) | ||
| relative_path = relpath(path, self.root_dir) | ||
|
|
||
|
|
@@ -469,7 +467,7 @@ def remove_unused_links(self, used): | |
| continue | ||
|
|
||
| actual_inode = get_inode(path) | ||
| actual_mtime, _ = get_mtime_and_size(path, self.repo.dvcignore) | ||
| actual_mtime, _ = get_mtime_and_size(path, self.repo.tree) | ||
|
|
||
| if inode == actual_inode and mtime == actual_mtime: | ||
| logger.debug("Removing '{}' as unused link.".format(path)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ | |
| from dvc.utils import fspath | ||
| from dvc.utils import fspath_py35 | ||
| from dvc.utils import relpath | ||
| from dvc.utils import walk_files | ||
| from dvc.utils.compat import str | ||
|
|
||
|
|
||
|
|
@@ -35,11 +34,15 @@ def get_inode(path): | |
| return inode | ||
|
|
||
|
|
||
| def get_mtime_and_size(path, dvcignore): | ||
| 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 = {} | ||
| for file_path in walk_files(path, dvcignore): | ||
| for file_path in tree.walk_files(path): | ||
| try: | ||
| stat = os.stat(file_path) | ||
| except OSError as exc: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check that path is not dvcignored to be entirely safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we should check if its ignored, a path can be both file and be ignored at the same time. What is the reasoning for that?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if file is ignored then it should not be visible, i.e. tree should pretend it doesn't exist. This is not an issue for now because we only open files that we walk, probably.
I see at least one issue though
dvc pipeline show ignored.dvcwill actually instantiate this ignored stage, and we will get a puzzlingKeyErrorlater.We may postpone this though because this might be solved in various ways.