get/import: more meaningful message on NoRemoteError

This commit is contained in:
pawel
2019-11-11 12:53:24 +01:00
parent 947b39f47a
commit deba7e95da
3 changed files with 19 additions and 1 deletions
+7
View File
@@ -328,3 +328,10 @@ class CheckoutError(DvcException):
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
View File
@@ -3,9 +3,11 @@ import os
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:
+8 -1
View File
@@ -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)