cli: make operation to undo or restore to a positional argument

I originally made the operation argument a named argument
(`--operation`) to allow for a change ID to be passed as a positional
argument, matching e.g. `hg revert -r <rev> <path>`. However, even if
we add support for undoing changes only to certain change IDs, it's
going to be done much less frequently than full undo/restore. We can
therefore make that a named argument if we ever add it.
This commit is contained in:
Martin von Zweigbergk 2022-04-24 12:31:54 -07:00 committed by Martin von Zweigbergk
parent 0058236a43
commit 8744015f33
3 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Breaking changes
* `jj [op] undo` and `jj op restore` used to take the operation to undo or
restore to as an argument to `-o/--operation`. It is now a positional
argument instead (i.e. `jj undo -o abc123` is now written `jj undo abc123`).
### New features
* `jj rebase` now accepts a `--branch/-b <revision>` argument, which can be used

View File

@ -1527,7 +1527,7 @@ struct OperationLogArgs {}
#[derive(clap::Args, Clone, Debug)]
struct OperationRestoreArgs {
/// The operation to restore to
#[clap(long, alias = "op", short, default_value = "@")]
#[clap(default_value = "@")]
operation: String,
}
@ -1535,7 +1535,7 @@ struct OperationRestoreArgs {
#[derive(clap::Args, Clone, Debug)]
struct OperationUndoArgs {
/// The operation to undo
#[clap(long, alias = "op", short, default_value = "@")]
#[clap(default_value = "@")]
operation: String,
}

View File

@ -35,7 +35,7 @@ fn test_undo_rewrite_with_child() {
o modified
o
"###);
test_env.jj_cmd_success(&repo_path, &["undo", "-o", &op_id_hex]);
test_env.jj_cmd_success(&repo_path, &["undo", &op_id_hex]);
// Since we undid the description-change, the child commit should now be on top
// of the initial commit