Revert "Enable forcing exp apply (unsaved files in the workspace)"

This reverts commit 3661b8998b.
This commit is contained in:
Peter Rowlands
2023-10-26 14:48:41 +09:00
committed by Peter Rowlands (변기호)
parent 4a0d56a793
commit d9b2e67a0b
2 changed files with 14 additions and 19 deletions
+13 -6
View File
@@ -4,13 +4,21 @@ import logging
from dvc.cli import completion
from dvc.cli.command import CmdBase
from dvc.cli.utils import append_doc_link
from dvc.ui import ui
logger = logging.getLogger(__name__)
class CmdExperimentsApply(CmdBase):
def run(self):
self.repo.experiments.apply(self.args.experiment, force=self.args.force)
if not self.args.force:
ui.write(
"The --no-force option is deprecated and will be removed in a future"
" DVC release. To revert the result of 'exp apply', run:\n"
"\n\tgit reset --hard\n"
"\tgit stash apply refs/exps/apply/stash\n"
)
self.repo.experiments.apply(self.args.experiment)
return 0
@@ -25,11 +33,10 @@ def add_parser(experiments_subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
experiments_apply_parser.add_argument(
"-f",
"--force",
action="store_true",
default=False,
help="Do not prompt when removing working directory files.",
"--no-force",
action="store_false",
dest="force",
help="Fail if this command would overwrite conflicting changes.",
)
experiments_apply_parser.add_argument(
"experiment", help="Experiment to be applied."
+1 -13
View File
@@ -27,19 +27,7 @@ def test_experiments_apply(dvc, scm, mocker):
assert cmd.run() == 0
m.assert_called_once_with(cmd.repo, "exp_rev", force=False)
def test_experiments_apply_force(dvc, scm, mocker):
cli_args = parse_args(["experiments", "apply", "exp_rev", "--force"])
assert cli_args.func == CmdExperimentsApply
cmd = cli_args.func(cli_args)
m = mocker.patch("dvc.repo.experiments.apply.apply", return_value={})
assert cmd.run() == 0
m.assert_called_once_with(cmd.repo, "exp_rev", force=True)
m.assert_called_once_with(cmd.repo, "exp_rev")
def test_experiments_diff(dvc, scm, mocker):