Skip to content

checkout: file replacing behaviour and unnecessary user interaction #2497

@dmpetrov

Description

@dmpetrov

Checkout requires unnecessary user interaction if a data file was modified:

$ cd example-get-started
$ dvc pull
$ echo 111 >> data/data.xml
$ git checkout - # jump to a previous commit
$ dvc checkout
WARNING: data 'data/data.xml' exists. Removing before checkout.
 83%|████████▎ |data/prepared                                                 5/6 [00:00<00:00, 1.32kfile/s]
file 'data/data.xml' is going to be removed. Are you sure you want to proceed? [y/n]
### <---- waiting for an input

It feels like dvc checkout needs to be consistent with git checkout which does not modify changed files but just warns about it (even without risk of deleting data):

$ vi prepare.dvc
$ git checkout -
M	prepare.dvc
Note: checking out '72e0f12cb2eca10f557c846bc706d0a5a321c9f3'.
...

Another advantage of the git-checkout is avoiding user interaction (y/n questions) which has benefits as discussed in #2027 (comment)

EDITED:
To be consistent to git checkout DVC should fail when a modified file in the workspace was based on an updated version of a file (compared to a file which needs to be checkout).

So, two dvc checkout behaviors are proposed none of them with user prompt: keep a modified file in workspace or fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhances DVCuiuser interface / interaction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions