diff: reimplement interface and tests from scratch#3229
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 |
* 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)
| cls._print_size(dct[diff.DIFF_SIZE]) | ||
| ) | ||
| return msg | ||
| for state, entries in diff.items() |
There was a problem hiding this comment.
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.
that's why the py3.5 test suite was failing! 🙈
There was a problem hiding this comment.
now iterating with an explicit order
| old = outs[a_ref] | ||
| new = outs[b_ref or "working tree"] | ||
|
|
||
| added = new - old |
There was a problem hiding this comment.
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.
this was mind-bending 👌 thanks for pointing it out, @Suor !
just added it)
There was a problem hiding this comment.
however, instead of repo.iter_outs, I defined a method to return the dictionary with paths and checksums, might refactor that one later
|
@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?