apply: add --no-force deprecation message

This commit is contained in:
Peter Rowlands
2023-02-20 14:36:38 +09:00
committed by Peter Rowlands (변기호)
parent d3182e0dd9
commit e218431f64
2 changed files with 16 additions and 2 deletions
+14
View File
@@ -4,12 +4,20 @@ 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):
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
@@ -24,6 +32,12 @@ def add_parser(experiments_subparsers, parent_parser):
help=EXPERIMENTS_APPLY_HELP,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
experiments_apply_parser.add_argument(
"--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."
).complete = completion.EXPERIMENT
+2 -2
View File
@@ -27,7 +27,7 @@ from .test_repro import common_arguments as repro_arguments
def test_experiments_apply(dvc, scm, mocker):
cli_args = parse_args(["experiments", "apply", "--no-force", "exp_rev"])
cli_args = parse_args(["experiments", "apply", "exp_rev"])
assert cli_args.func == CmdExperimentsApply
cmd = cli_args.func(cli_args)
@@ -35,7 +35,7 @@ def test_experiments_apply(dvc, scm, mocker):
assert cmd.run() == 0
m.assert_called_once_with(cmd.repo, "exp_rev", force=False)
m.assert_called_once_with(cmd.repo, "exp_rev")
def test_experiments_diff(dvc, scm, mocker):