Skip to content

Commit

Permalink
get/import: more meaningful message on NoRemoteError
Browse files Browse the repository at this point in the history
  • Loading branch information
pared committed Nov 11, 2019
1 parent 947b39f commit deba7e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,10 @@ def __init__(self, target_infos):

class CollectCacheError(DvcException):
pass


class RemoteNotSpecifiedInTargetRepoError(DvcException):
def __init__(self, url):
super(RemoteNotSpecifiedInTargetRepoError, self).__init__(
"No DVC remote is specified in target repository '{}'".format(url)
)
4 changes: 4 additions & 0 deletions dvc/repo/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

import shortuuid

from dvc.config import NoRemoteError
from dvc.exceptions import GetDVCFileError
from dvc.exceptions import NotDvcRepoError
from dvc.exceptions import OutputNotFoundError
from dvc.exceptions import RemoteNotSpecifiedInTargetRepoError
from dvc.exceptions import UrlNotDvcRepoError
from dvc.external_repo import external_repo
from dvc.path_info import PathInfo
Expand Down Expand Up @@ -56,6 +58,8 @@ def get(url, path, out=None, rev=None):
with o.repo.state:
o.checkout()

except NoRemoteError:
raise RemoteNotSpecifiedInTargetRepoError(url)
except NotDvcRepoError:
raise UrlNotDvcRepoError(url)
except OutputNotFoundError:
Expand Down
9 changes: 8 additions & 1 deletion dvc/repo/imp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from dvc.config import NoRemoteError
from dvc.exceptions import RemoteNotSpecifiedInTargetRepoError


def imp(self, url, path, out=None, rev=None):
erepo = {"url": url}
if rev is not None:
erepo["rev"] = rev

return self.imp_url(path, out=out, erepo=erepo, locked=True)
try:
return self.imp_url(path, out=out, erepo=erepo, locked=True)
except NoRemoteError:
raise RemoteNotSpecifiedInTargetRepoError(url)

0 comments on commit deba7e9

Please sign in to comment.