-
Notifications
You must be signed in to change notification settings - Fork 1.3k
checkout: fix output message #3297
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
86a1dae
3f2069c
9c7642e
2c52d00
f8094cd
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 |
|---|---|---|
|
|
@@ -15,7 +15,14 @@ def _cleanup_unused_links(repo): | |
| for out in stage.outs | ||
| if out.scheme == "local" | ||
| ] | ||
| repo.state.remove_unused_links(used) | ||
|
|
||
| unused = repo.state.get_unused_links(used) | ||
| for link in unused: | ||
| logger.info( | ||
| "Removing '{}' as it already exists in the current worktree.", link | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @jorgeorpinel - please review the messages in this PR
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't think of succinct messages. π’
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message is not very useful for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, it is pretty weird to split old
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes: #3297 (comment)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So you moved it just to not use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't consider separation of UI and business logic to be a weak argument. But probably as it's a cli app and already done this way on most of the places here, maybe it is.
I am fine, either way. Previously, I did not want to separate those too far off like you suggested below and tried to just get the stuff done. π
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see #3326 replaced this and only has a debug string change |
||
| ) | ||
| repo.state.remove_links(unused) | ||
| return bool(unused) | ||
|
|
||
|
|
||
| def get_all_files_numbers(pairs): | ||
|
|
@@ -34,9 +41,10 @@ def _checkout( | |
| ): | ||
| from dvc.stage import StageFileDoesNotExistError, StageFileBadNameError | ||
|
|
||
| cleaned = False | ||
| if not targets: | ||
| targets = [None] | ||
| _cleanup_unused_links(self) | ||
| cleaned = _cleanup_unused_links(self) | ||
|
|
||
| pairs = set() | ||
| for target in targets: | ||
|
|
@@ -52,7 +60,7 @@ def _checkout( | |
| raise CheckoutErrorSuggestGit(target) from exc | ||
|
|
||
| total = get_all_files_numbers(pairs) | ||
| if total == 0: | ||
| if total == 0 and not cleaned: | ||
| logger.info("Nothing to do") | ||
| failed = [] | ||
| with Tqdm( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -443,36 +443,37 @@ def save_link(self, path_info): | |
| ) | ||
| self._execute(cmd, (relative_path, self._to_sqlite(inode), mtime)) | ||
|
|
||
| def remove_unused_links(self, used): | ||
| """Removes all saved links except the ones that are used. | ||
| def get_unused_links(self, used): | ||
| """Returns all saved links except the ones that are used. | ||
|
|
||
| Args: | ||
| used (list): list of used links that should not be removed. | ||
| used (list): list of used links | ||
| """ | ||
| unused = [] | ||
|
|
||
| self._execute("SELECT * FROM {}".format(self.LINK_STATE_TABLE)) | ||
| for row in self.cursor: | ||
| relpath, inode, mtime = row | ||
| relative_path, inode, mtime = row | ||
| inode = self._from_sqlite(inode) | ||
| path = os.path.join(self.root_dir, relpath) | ||
| path = os.path.join(self.root_dir, relative_path) | ||
|
|
||
| if path in used: | ||
| continue | ||
|
|
||
| if not os.path.exists(path): | ||
| if path in used or not os.path.exists(path): | ||
| continue | ||
|
|
||
| actual_inode = get_inode(path) | ||
| actual_mtime, _ = get_mtime_and_size(path, self.repo.tree) | ||
|
|
||
| if inode == actual_inode and mtime == actual_mtime: | ||
| logger.debug("Removing '{}' as unused link.", path) | ||
| remove(path) | ||
| unused.append(relpath) | ||
| if (inode, mtime) == (actual_inode, actual_mtime): | ||
| unused.append(relative_path) | ||
|
|
||
| return unused | ||
|
|
||
| def remove_links(self, links): | ||
| for link in links: | ||
| remove(os.path.join(self.root_dir, link)) | ||
|
Comment on lines
+472
to
+473
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more natural refactor would split old |
||
|
|
||
| for chunk_unused in to_chunks( | ||
| unused, chunk_size=SQLITE_MAX_VARIABLES_NUMBER | ||
| links, chunk_size=SQLITE_MAX_VARIABLES_NUMBER | ||
| ): | ||
| cmd = "DELETE FROM {} WHERE path IN ({})".format( | ||
| self.LINK_STATE_TABLE, ",".join(["?"] * len(chunk_unused)) | ||
|
|
||
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.
Not sure about converting it to info. Maybe let's remove it for good? Or make it
debug?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.
This was the result of the discussion from #2979, no?
Also: #2979 (comment)
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.
@skshetry Good point, that needs to be clarified. Left a comment there.