Skip to content

Commit

Permalink
diff: improve RevError message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr. Outis committed Jan 27, 2020
1 parent a12d81f commit 3c6b52b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions dvc/scm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def __init__(self, url, path):


class RevError(SCMError):
def __init__(self, url, rev):
super().__init__(
"failed to access revision '{}' for repo '{}'".format(rev, url)
)
pass


class Base(object):
Expand Down
10 changes: 7 additions & 3 deletions dvc/scm/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def clone(url, to_path, rev=None):
try:
repo.checkout(rev)
except git.exc.GitCommandError as exc:
raise RevError(url, rev) from exc
raise RevError(
"failed to access revision '{}' for repo '{}'".format(
rev, url
)
) from exc

return repo

Expand Down Expand Up @@ -367,8 +371,8 @@ def resolve_rev(self, rev):

try:
return self.repo.git.rev_parse(rev)
except GitCommandError as exc:
raise RevError(url=self.root_dir, rev=rev) from exc
except GitCommandError:
raise RevError("unknown Git revision '{}'".format(rev))

def close(self):
self.repo.close()
Expand Down
4 changes: 1 addition & 3 deletions tests/func/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ def test_refs(tmp_dir, scm, dvc):
],
}

with pytest.raises(
DvcException, match=r"failed to access revision 'missing'"
):
with pytest.raises(DvcException, match=r"unknown Git revision 'missing'"):
dvc.diff("missing")


Expand Down

0 comments on commit 3c6b52b

Please sign in to comment.