mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
checkout: add --with-deps support
Fixes #1296 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -184,6 +184,13 @@ def parse_args(argv=None):
|
||||
parents=[parent_parser],
|
||||
description=CHECKOUT_HELP,
|
||||
help=CHECKOUT_HELP)
|
||||
checkout_parser.add_argument(
|
||||
'-d',
|
||||
'--with-deps',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Checkout all dependencies of the '
|
||||
'specified target.')
|
||||
checkout_parser.add_argument(
|
||||
'targets',
|
||||
nargs='*',
|
||||
|
||||
@@ -7,5 +7,6 @@ class CmdCheckout(CmdBase):
|
||||
self.project.checkout()
|
||||
else:
|
||||
for target in self.args.targets:
|
||||
self.project.checkout(target=target)
|
||||
self.project.checkout(target=target,
|
||||
with_deps=self.args.with_deps)
|
||||
return 0
|
||||
|
||||
+4
-3
@@ -449,11 +449,12 @@ class Project(object):
|
||||
used.append(out.path)
|
||||
self.state.remove_unused_links(used)
|
||||
|
||||
def checkout(self, target=None):
|
||||
def checkout(self, target=None, with_deps=False):
|
||||
all_stages = self.active_stages()
|
||||
|
||||
if target:
|
||||
stages = [Stage.load(self, target)]
|
||||
stages = self._collect(target,
|
||||
with_deps=with_deps)
|
||||
else:
|
||||
stages = all_stages
|
||||
|
||||
@@ -701,7 +702,7 @@ class Project(object):
|
||||
all_tags=all_tags,
|
||||
show_checksums=show_checksums,
|
||||
with_deps=with_deps)
|
||||
self.checkout(target=target)
|
||||
self.checkout(target=target, with_deps=with_deps)
|
||||
|
||||
def _local_status(self, target=None):
|
||||
status = {}
|
||||
|
||||
@@ -246,3 +246,18 @@ class TestCheckoutNotCachedFile(TestDvc):
|
||||
outs_no_cache=['out'])
|
||||
|
||||
self.dvc.checkout()
|
||||
|
||||
|
||||
class TestCheckoutWithDeps(TestRepro):
|
||||
def test(self):
|
||||
os.unlink(self.FOO)
|
||||
os.unlink(self.file1)
|
||||
|
||||
self.assertFalse(os.path.exists(self.FOO))
|
||||
self.assertFalse(os.path.exists(self.file1))
|
||||
|
||||
ret = main(['checkout', self.file1_stage, '--with-deps'])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
self.assertTrue(os.path.exists(self.FOO))
|
||||
self.assertTrue(os.path.exists(self.file1))
|
||||
|
||||
Reference in New Issue
Block a user