mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-23 07:18:27 +01:00
Merge pull request #2164 from efiop/1011
dvc: destroy: don't remove data
This commit is contained in:
+1
-1
@@ -3,6 +3,6 @@ import shutil
|
||||
|
||||
def destroy(self):
|
||||
for stage in self.stages():
|
||||
stage.remove()
|
||||
stage.remove(remove_outs=False)
|
||||
|
||||
shutil.rmtree(self.dvc_dir)
|
||||
|
||||
+5
-2
@@ -296,8 +296,11 @@ class Stage(object):
|
||||
for out in self.outs:
|
||||
out.unprotect()
|
||||
|
||||
def remove(self, force=False):
|
||||
self.remove_outs(ignore_remove=True, force=force)
|
||||
def remove(self, force=False, remove_outs=True):
|
||||
if remove_outs:
|
||||
self.remove_outs(ignore_remove=True, force=force)
|
||||
else:
|
||||
self.unprotect_outs()
|
||||
os.unlink(self.path)
|
||||
|
||||
def reproduce(
|
||||
|
||||
+21
-14
@@ -1,21 +1,28 @@
|
||||
import os
|
||||
|
||||
from dvc.main import main
|
||||
|
||||
from tests.func.test_repro import TestRepro
|
||||
from dvc.system import System
|
||||
|
||||
|
||||
class TestDestroyNoConfirmation(TestRepro):
|
||||
def test(self):
|
||||
ret = main(["destroy"])
|
||||
self.assertNotEqual(ret, 0)
|
||||
def test_destroy(repo_dir, dvc_repo):
|
||||
# NOTE: using symlink to ensure that data was unprotected after `destroy`
|
||||
dvc_repo.config.set("cache", "type", "symlink")
|
||||
|
||||
foo_stage, = dvc_repo.add(repo_dir.FOO)
|
||||
data_dir_stage, = dvc_repo.add(repo_dir.DATA_DIR)
|
||||
|
||||
class TestDestroyForce(TestRepro):
|
||||
def test(self):
|
||||
ret = main(["destroy", "-f"])
|
||||
self.assertEqual(ret, 0)
|
||||
dvc_repo.destroy()
|
||||
|
||||
self.assertFalse(os.path.exists(self.dvc.dvc_dir))
|
||||
self.assertFalse(os.path.exists(self.file1_stage))
|
||||
self.assertFalse(os.path.exists(self.file1))
|
||||
assert not os.path.exists(dvc_repo.dvc_dir)
|
||||
assert not os.path.exists(foo_stage.path)
|
||||
assert not os.path.exists(data_dir_stage.path)
|
||||
|
||||
assert os.path.isfile(repo_dir.FOO)
|
||||
assert os.path.isdir(repo_dir.DATA_DIR)
|
||||
assert os.path.isfile(repo_dir.DATA)
|
||||
assert os.path.isdir(repo_dir.DATA_SUB_DIR)
|
||||
assert os.path.isfile(repo_dir.DATA_SUB)
|
||||
|
||||
assert not System.is_symlink(repo_dir.FOO)
|
||||
assert not System.is_symlink(repo_dir.DATA_DIR)
|
||||
assert not System.is_symlink(repo_dir.DATA)
|
||||
assert not System.is_symlink(repo_dir.DATA_SUB)
|
||||
|
||||
Reference in New Issue
Block a user