import: Output as on optional argument (#1351) (#1378)

* import: Output as on optional argument

Close #1335

* Use tempfile to prevent circular dependencies
This commit is contained in:
Mr. Outis
2018-11-28 23:35:37 +02:00
committed by Ruslan Kuprieiev
parent c6b8be8f8a
commit 38d666d77d
2 changed files with 21 additions and 4 deletions
+8 -4
View File
@@ -326,10 +326,11 @@ class RemoteLOCAL(RemoteBase):
entry_checksum_info = {self.PARAM_MD5: m}
if self.changed(entry_info, entry_checksum_info):
if force or self._already_cached(p):
remove(p)
else:
self._safe_remove(p)
if os.path.exists(p):
if force or self._already_cached(p):
remove(p)
else:
self._safe_remove(p)
self.link(c, p)
@@ -346,6 +347,9 @@ class RemoteLOCAL(RemoteBase):
def _already_cached(self, path):
current_md5 = self.state.update(path)
if not current_md5:
return False
return not self.changed_cache(current_md5)
def _discard_working_directory_changes(self, path, dir_info, force=False):
+13
View File
@@ -359,3 +359,16 @@ class TestCheckoutWithDeps(TestRepro):
self.assertTrue(os.path.exists(self.FOO))
self.assertTrue(os.path.exists(self.file1))
class TestCheckoutDirectory(TestRepro):
def test(self):
stage = self.dvc.add(self.DATA_DIR)[0]
shutil.rmtree(self.DATA_DIR)
self.assertFalse(os.path.exists(self.DATA_DIR))
ret = main(['checkout', stage.path])
self.assertEqual(ret, 0)
self.assertTrue(os.path.exists(self.DATA_DIR))