Skip to content

Commit

Permalink
cli: make operation to undo or restore to a positional argument
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinvonz committed Apr 26, 2022
1 parent 0058236 commit 8744015
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,15 +1527,15 @@ 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,
}

/// Undo an operation
#[derive(clap::Args, Clone, Debug)]
struct OperationUndoArgs {
/// The operation to undo
#[clap(long, alias = "op", short, default_value = "@")]
#[clap(default_value = "@")]
operation: String,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_undo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8744015

Please sign in to comment.