Skip to content

Commit

Permalink
diff: remove --target
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr. Outis committed Jan 27, 2020
1 parent 3c6b52b commit 7f6324e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 47 deletions.
13 changes: 1 addition & 12 deletions dvc/command/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def _digest(checksum):

def run(self):
try:
diff = self.repo.diff(
self.args.a_ref, self.args.b_ref, target=self.args.target
)
diff = self.repo.diff(self.args.a_ref, self.args.b_ref)

if not any(diff.values()):
return 0
Expand Down Expand Up @@ -124,15 +122,6 @@ def add_parser(subparsers, parent_parser):
),
nargs="?",
)
diff_parser.add_argument(
"-t",
"--target",
help=(
"Source path to a data file or directory. Default None. "
"If not specified, compares all files and directories "
"that are under DVC control in the current working space."
),
)
diff_parser.add_argument(
"--show-json",
help="Format the output into a JSON",
Expand Down
5 changes: 1 addition & 4 deletions dvc/repo/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ def _diffables_from_output(output):


@locked
def diff(self, a_ref="HEAD", b_ref=None, *, target=None):
def diff(self, a_ref="HEAD", b_ref=None):
"""
By default, it compares the working tree with the last commit's tree.
When a `target` path is given, it only shows that file's comparison.
This implementation differs from `git diff` since DVC doesn't have
the concept of `index`, but it keeps the same interface, thus,
`dvc diff` would be the same as `dvc diff HEAD`.
Expand All @@ -67,7 +65,6 @@ def diff(self, a_ref="HEAD", b_ref=None, *, target=None):
for stage in self.stages
for out in stage.outs
for diffable in _diffables_from_output(out)
if not target or target == str(out)
)

old = outs[a_ref]
Expand Down
2 changes: 1 addition & 1 deletion scripts/completion/dvc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _dvc_checkout='-d --with-deps -R --recursive -f --force --relink $(compgen -G *.
_dvc_commit='-f --force -d --with-deps -R --recursive $(compgen -G *.dvc)'
_dvc_config='-u --unset --local --system --global'
_dvc_destroy='-f --force'
_dvc_diff='-t --target --show-json --checksums'
_dvc_diff='-t --show-json --checksums'
_dvc_fetch='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive $(compgen -G *.dvc)'
_dvc_get_url=''
_dvc_get='-o --out --rev --show-url'
Expand Down
1 change: 0 additions & 1 deletion scripts/completion/dvc.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ _dvc_destroy=(
)

_dvc_diff=(
{-t,--target}"[Source path to a data file or directory.]:Target files:"
"--show-json[Format the output into a JSON]"
"--checksums[Display checksums for each entry]"
{1,2}":Git revision (e.g. branch, tag, SHA):"
Expand Down
29 changes: 0 additions & 29 deletions tests/func/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,6 @@ def test_refs(tmp_dir, scm, dvc):
dvc.diff("missing")


def test_target(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("foo", "foo")
tmp_dir.dvc_gen("bar", "bar")
scm.add([".gitignore", "foo.dvc", "bar.dvc"])
scm.commit("lowercase")

tmp_dir.dvc_gen("foo", "FOO")
tmp_dir.dvc_gen("bar", "BAR")
scm.add(["foo.dvc", "bar.dvc"])
scm.commit("uppercase")

assert dvc.diff("HEAD~1", target="foo") == {
"added": [],
"deleted": [],
"modified": [
{
"filename": "foo",
"checksum": {"old": digest("foo"), "new": digest("FOO")},
}
],
}

assert dvc.diff("HEAD~1", target="missing") == {
"added": [],
"deleted": [],
"modified": [],
}


def test_directories(tmp_dir, scm, dvc):
tmp_dir.dvc_gen({"dir": {"1": "1", "2": "2"}}, commit="add a directory")
tmp_dir.dvc_gen({"dir": {"3": "3"}}, commit="add a file")
Expand Down

0 comments on commit 7f6324e

Please sign in to comment.