mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
apply: add --no-force deprecation message
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
d3182e0dd9
commit
e218431f64
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user