Requested by Al on discord. Currently if a user accidentally runs dvc checkout <branch> he gets:
(3.7.0-dvc) ➜ myrepo git:(ololo) ✗ dvc checkout master
Error: unexpected error - 'master' does not exist.
Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
Let's add a static warning that says something like "Do you mean git checkout <branch>?`".
I can have a look at that one
That would be amazing @tdeboissiere ! Thank you! :slightly_smiling_face: Please let us know if you need anything.
Sure thing !
The error message occurs during a Stage.load call. Stage.load is also called by unrelated dvc commands, such as dvc remove. This means I need a way to identify what dvc command led to the Stage.load call, in order to display the warning message only if that dvc command was a checkout
The most straightforward way would be to add a keyword argument such as from_checkout=False if True, we can then change the error message to suggest git checkout.
While that would work, it is not particularly elegant. Thoughts ?
Edit
Would it make sense to implement a mechanism to easily find out which dvc command has been launched ?
Maybe something like:
@tdeboissiere How about we raise a special exception when dvc file doesn't exist and then would catch it either in dvc/project.py:Project.checkout() or in dvc/command/checkout.py?
Most helpful comment
I can have a look at that one