diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 07a0ce8061..9bab2eeaf7 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -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) + ) diff --git a/dvc/repo/get.py b/dvc/repo/get.py index 0117006840..1f1afdb6d9 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -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 @@ -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: diff --git a/dvc/repo/imp.py b/dvc/repo/imp.py index 68ead389b6..d15697dbd1 100644 --- a/dvc/repo/imp.py +++ b/dvc/repo/imp.py @@ -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)