Repository: iterative/dvc

Issue:
Don't require a lock for the dvc root command
Is there any way that the `dvc root` would change in the middle of some `dvc` command that acquired lock? If not, I think `dvc root` could simply skip acquiring a lock so it can be used freely.

Discussion:

Patch:
diff --git a/dvc/command/root.py b/dvc/command/root.py
index 8d83f5c89..feff9cb01 100644
--- a/dvc/command/root.py
+++ b/dvc/command/root.py
@@ -4,6 +4,9 @@ from dvc.command.base import CmdBase
 
 
 class CmdRoot(CmdBase):
+    def run_cmd(self):
+        return self.run()
+
     def run(self):
         self.project.logger.info(os.path.relpath(self.project.root_dir))
         return 0


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index 5f9d9ff02..93e8d5c9b 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -28,6 +28,11 @@ class TestConfigCLI(TestDvc):
         ret = main(['root'])
         self.assertEqual(ret, 0)
 
+        # NOTE: check that `dvc root` is not blocked with dvc lock
+        with self.dvc.lock:
+            ret = main(['root'])
+        self.assertEqual(ret, 0)
+
     def _do_test(self, local=False):
         section = 'setsection'
         field = 'setfield'