-
Notifications
You must be signed in to change notification settings - Fork 1.3k
diff: reimplement interface and tests from scratch #3229
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
Conversation
|
@MrOutis What is the point of these tests if they are all commented out and TODos? |
I think the ticket was saying that we shouldn't show checksums by default. Wouldn't bother with introducing |
Suor
left a 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.
Looks cool so far.
* OSError -> FileNotFoundError * Make `a_ref` optional * Use absolute imports for unrelated packages * Relpath: `str(output.path_info)` -> `str(output)` * `a_ref` defaults to `HEAD` at the signature and parser level
@Suor, could you please take a look again? I did quite a lot of changes)
dvc/command/diff.py
Outdated
| cls._print_size(dct[diff.DIFF_SIZE]) | ||
| ) | ||
| return msg | ||
| for state, entries in diff.items() |
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.
The order of dict keys are not preserved before Python 3.6, so in Python 3.5 the sections will go in random order.
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.
that's why the py3.5 test suite was failing! 🙈
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.
now iterating with an explicit order
dvc/repo/diff.py
Outdated
| old = outs[a_ref] | ||
| new = outs[b_ref or "working tree"] | ||
|
|
||
| added = new - old |
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.
You are abusing set mechanics and __eq__ here and below, this results into iterating over intersection very tricky and unobvious. People reading this code will expect it to conform to:
old - (old ^ new) == new - (old ^ new) == old & newwhich it doesn't. And we don't need this anyway as we may simply use dicts:
saved_tree = repo.tree
try:
repo.tree = get_ree(a_ref)
# we don't have repo.outs, but might be we should,
# or make it repo.iter_outs()?
old = {str(out): out.checksum for out in repo.outs}
repo.tree = get_ree(b_ref)
new = {str(out): out.checksum for out in repo.outs}
finally:
repo.tree = saved_tree
# set efficiently converts dict keys to set, we only compare names here
added = {name: new[name] for name in set(new) - set(old)}
deleted = {name: old[name] for name in set(old) - set(new)}
changed = {
name: {"old": old[name], "new": new[name]}
for name in set(old) & set(new)
if old[name] != new[name]
}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 mind-bending 👌 thanks for pointing it out, @Suor !
just added it)
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.
however, instead of repo.iter_outs, I defined a method to return the dictionary with paths and checksums, might refactor that one later
dmpetrov
left a 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.
|
@MrOutis please check the tests, looks like there are some dict ordering issues. |
|
@efiop , doing it right now |
Co-authored-by: @jorgeorpinel <jorge@opinel.com>
@Suor, I changed the diff logic to use dicts
|
What's the fastest way to see if this is released or get notified when it is? I don't think it's included in |
Close: #2982, #2998, #2999, #1893, #2372
Related: #770
--targetoption.--checksumoption is provided.--show-jsonoption is given.dvc diffwhen there's no cache available.Questions:
--recursiveoption to explicitly recurse directory outputs?renamedfiles?