exceptions: migrate other scm exceptions to internal

This commit is contained in:
Saugat Pachhai (सौगात)
2021-11-23 19:21:51 +02:00
committed by Ruslan Kuprieiev
parent f2f4227656
commit f76ef84c88
8 changed files with 28 additions and 15 deletions
+7 -2
View File
@@ -46,7 +46,12 @@ def apply(repo, rev, force=True, **kwargs):
else:
workspace = None
repo.scm.merge(exp_rev, commit=False)
from dvc.scm.exceptions import SCMError as _SCMError
try:
repo.scm.merge(exp_rev, commit=False)
except _SCMError as exc:
raise SCMError(str(exc))
if workspace:
try:
@@ -61,7 +66,7 @@ def apply(repo, rev, force=True, **kwargs):
repo.scm.reset(hard=True)
repo.scm.stash.pop()
raise ApplyConflictError(rev) from exc
except SCMError as exc:
except _SCMError as exc:
raise ApplyConflictError(rev) from exc
repo.scm.stash.drop()
repo.scm.reset()
+10 -4
View File
@@ -26,11 +26,17 @@ def SCM(
Returns:
dvc.scm.base.Base: SCM instance.
"""
from dvc.scm.base import SCMError
from dvc.scm.exceptions import SCMError as InternalSCMError
if no_scm:
return NoSCM(root_dir)
return Git(root_dir, search_parent_directories=search_parent_directories)
try:
if no_scm:
return NoSCM(root_dir)
return Git(
root_dir, search_parent_directories=search_parent_directories
)
except InternalSCMError as exc:
raise SCMError(str(exc))
def clone(url: str, to_path: str, **kwargs):
+1 -1
View File
@@ -10,7 +10,7 @@ from typing import (
Union,
)
from dvc.scm.base import SCMError
from dvc.scm.exceptions import SCMError
from ..objects import GitObject
+1 -2
View File
@@ -19,8 +19,7 @@ from typing import (
from funcy import cached_property
from dvc.progress import Tqdm
from dvc.scm.base import SCMError
from dvc.scm.exceptions import AuthError, InvalidRemote
from dvc.scm.exceptions import AuthError, InvalidRemote, SCMError
from dvc.utils import relpath
from ...objects import GitObject
+6 -2
View File
@@ -17,8 +17,12 @@ from typing import (
from funcy import ignore
from dvc.progress import Tqdm
from dvc.scm.base import SCMError
from dvc.scm.exceptions import CloneError, MergeConflictError, RevError
from dvc.scm.exceptions import (
CloneError,
MergeConflictError,
RevError,
SCMError,
)
from dvc.utils import fix_env, is_binary, relpath
from ..objects import GitCommit, GitObject
+1 -2
View File
@@ -17,8 +17,7 @@ from typing import (
from funcy import cached_property
from dvc.scm.base import SCMError
from dvc.scm.exceptions import MergeConflictError, RevError
from dvc.scm.exceptions import MergeConflictError, RevError, SCMError
from dvc.utils import relpath
from ..objects import GitCommit, GitObject
+1 -1
View File
@@ -3,7 +3,7 @@
import logging
from typing import Optional
from dvc.scm.base import SCMError
from dvc.scm.exceptions import SCMError
logger = logging.getLogger(__name__)
+1 -1
View File
@@ -2,7 +2,7 @@ import os
import pytest
from dvc.scm.base import SCMError
from dvc.scm.exceptions import SCMError
# Behaves the same as SCM but will test against all supported Git backends.