mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dvc.scm.scm_context -> dvc.repo.scm_context.scm_context
The `dvc/scm/__init__.py:scm_context` works with `Repo` objects and is used mostly in `dvc/repo/...`, so it is better to put it in `dvc/repo/scm_context.py`. Fix #1769
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import dvc.prompt as prompt
|
||||
import dvc.logger as logger
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
from dvc.scm import scm_context
|
||||
from dvc.repo.scm_context import scm_context
|
||||
from dvc.stage import Stage
|
||||
from dvc.utils import walk_files
|
||||
from dvc.exceptions import RecursiveAddingWhileUsingFilename
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
from dvc.scm import scm_context
|
||||
from dvc.repo.scm_context import scm_context
|
||||
|
||||
|
||||
@scm_context
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from dvc.exceptions import MoveNotDataSourceError
|
||||
from dvc.scm import scm_context
|
||||
from dvc.repo.scm_context import scm_context
|
||||
|
||||
|
||||
def _expand_target_path(from_path, to_path):
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
import dvc.logger as logger
|
||||
from dvc.exceptions import ReproductionError
|
||||
from dvc.scm import scm_context
|
||||
from dvc.repo.scm_context import scm_context
|
||||
|
||||
|
||||
def _reproduce_stage(stages, node, force, dry, interactive, no_commit):
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from dvc.scm import scm_context
|
||||
from dvc.repo.scm_context import scm_context
|
||||
|
||||
|
||||
@scm_context
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
def scm_context(method):
|
||||
def run(repo, *args, **kw):
|
||||
try:
|
||||
result = method(repo, *args, **kw)
|
||||
repo.scm.reset_ignores()
|
||||
repo.scm.remind_to_track()
|
||||
return result
|
||||
except Exception as e:
|
||||
repo.scm.cleanup_ignores()
|
||||
raise e
|
||||
|
||||
return run
|
||||
@@ -5,8 +5,6 @@ from __future__ import unicode_literals
|
||||
from dvc.scm.base import Base
|
||||
from dvc.scm.git import Git
|
||||
|
||||
import dvc
|
||||
|
||||
|
||||
# just a sugar to point that this is an actual implementation for a dvc
|
||||
# project under no SCM control
|
||||
@@ -29,19 +27,3 @@ def SCM(root_dir, repo=None): # pylint: disable=invalid-name
|
||||
return Git(root_dir, repo=repo)
|
||||
|
||||
return NoSCM(root_dir, repo=repo)
|
||||
|
||||
|
||||
def scm_context(method):
|
||||
def run(*args, **kw):
|
||||
repo = args[0]
|
||||
assert isinstance(repo, dvc.repo.Repo)
|
||||
try:
|
||||
result = method(*args, **kw)
|
||||
repo.scm.reset_ignores()
|
||||
repo.scm.remind_to_track()
|
||||
return result
|
||||
except Exception as e:
|
||||
repo.scm.cleanup_ignores()
|
||||
raise e
|
||||
|
||||
return run
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from dvc.repo import Repo
|
||||
from dvc.scm import scm_context, NoSCM
|
||||
from dvc.repo.scm_context import scm_context
|
||||
from dvc.scm import NoSCM
|
||||
from unittest import TestCase
|
||||
import mock
|
||||
|
||||
|
||||
Reference in New Issue
Block a user