mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-24 06:19:42 +00:00
cli: provide short flags for rev ranges
This commit is contained in:
parent
c0a9e20222
commit
ac0e531de5
8 changed files with 40 additions and 24 deletions
|
@ -51,6 +51,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||
* The `tags()` revset function now takes an optional `pattern` argument,
|
||||
mirroring that of `bookmarks()`.
|
||||
|
||||
* Several commands now support `-f/-t` shorthands for `--from/--to`:
|
||||
- `diff`
|
||||
- `diffedit`
|
||||
- `interdiff`
|
||||
- `op diff`
|
||||
- `restore`
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* `jj config unset <TABLE-NAME>` no longer removes a table (such as `[ui]`.)
|
||||
|
|
|
@ -51,10 +51,10 @@ pub(crate) struct DiffArgs {
|
|||
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
revision: Option<RevisionArg>,
|
||||
/// Show changes from this revision
|
||||
#[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
from: Option<RevisionArg>,
|
||||
/// Show changes to this revision
|
||||
#[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
to: Option<RevisionArg>,
|
||||
/// Restrict the diff to these paths
|
||||
#[arg(value_hint = clap::ValueHint::AnyPath)]
|
||||
|
|
|
@ -55,12 +55,20 @@ pub(crate) struct DiffeditArgs {
|
|||
/// Show changes from this revision
|
||||
///
|
||||
/// Defaults to @ if --to is specified.
|
||||
#[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(
|
||||
long, short,
|
||||
conflicts_with = "revision",
|
||||
add = ArgValueCandidates::new(complete::all_revisions),
|
||||
)]
|
||||
from: Option<RevisionArg>,
|
||||
/// Edit changes in this revision
|
||||
///
|
||||
/// Defaults to @ if --from is specified.
|
||||
#[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::mutable_revisions))]
|
||||
#[arg(
|
||||
long, short,
|
||||
conflicts_with = "revision",
|
||||
add = ArgValueCandidates::new(complete::mutable_revisions),
|
||||
)]
|
||||
to: Option<RevisionArg>,
|
||||
/// Specify diff editor to be used
|
||||
#[arg(long, value_name = "NAME")]
|
||||
|
|
|
@ -36,10 +36,10 @@ use crate::ui::Ui;
|
|||
#[command(mut_arg("ignore_space_change", |a| a.short('b')))]
|
||||
pub(crate) struct InterdiffArgs {
|
||||
/// Show changes from this revision
|
||||
#[arg(long, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
from: Option<RevisionArg>,
|
||||
/// Show changes to this revision
|
||||
#[arg(long, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
to: Option<RevisionArg>,
|
||||
/// Restrict the diff to these paths
|
||||
#[arg(value_hint = clap::ValueHint::AnyPath)]
|
||||
|
|
|
@ -65,14 +65,14 @@ pub struct OperationDiffArgs {
|
|||
operation: Option<String>,
|
||||
/// Show repository changes from this operation
|
||||
#[arg(
|
||||
long,
|
||||
long, short,
|
||||
conflicts_with = "operation",
|
||||
add = ArgValueCandidates::new(complete::operations),
|
||||
)]
|
||||
from: Option<String>,
|
||||
/// Show repository changes to this operation
|
||||
#[arg(
|
||||
long,
|
||||
long, short,
|
||||
conflicts_with = "operation",
|
||||
add = ArgValueCandidates::new(complete::operations),
|
||||
)]
|
||||
|
|
|
@ -48,10 +48,10 @@ pub(crate) struct RestoreArgs {
|
|||
#[arg(value_hint = clap::ValueHint::AnyPath)]
|
||||
paths: Vec<String>,
|
||||
/// Revision to restore from (source)
|
||||
#[arg(long, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
|
||||
from: Option<RevisionArg>,
|
||||
/// Revision to restore into (destination)
|
||||
#[arg(long, add = ArgValueCandidates::new(complete::mutable_revisions))]
|
||||
#[arg(long, short, add = ArgValueCandidates::new(complete::mutable_revisions))]
|
||||
to: Option<RevisionArg>,
|
||||
/// Undo the changes in a revision as compared to the merge of its parents.
|
||||
///
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: cli/tests/test_generate_md_cli_help.rs
|
||||
description: "AUTO-GENERATED FILE, DO NOT EDIT. This cli reference is generated by a test as an `insta` snapshot. MkDocs includes this snapshot from docs/cli-reference.md."
|
||||
snapshot_kind: text
|
||||
---
|
||||
<!-- BEGIN MARKDOWN-->
|
||||
|
||||
|
@ -689,8 +690,8 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||
* `-r`, `--revision <REVISION>` — Show changes in this revision, compared to its parent(s)
|
||||
|
||||
If the revision is a merge commit, this shows changes *from* the automatic merge of the contents of all of its parents *to* the contents of the revision itself.
|
||||
* `--from <FROM>` — Show changes from this revision
|
||||
* `--to <TO>` — Show changes to this revision
|
||||
* `-f`, `--from <FROM>` — Show changes from this revision
|
||||
* `-t`, `--to <TO>` — Show changes to this revision
|
||||
* `-s`, `--summary` — For each path, show only whether it was modified, added, or deleted
|
||||
* `--stat` — Show a histogram of the changes
|
||||
* `--types` — For each path, show only its type before and after
|
||||
|
@ -729,10 +730,10 @@ See `jj restore` if you want to move entire files from one revision to another.
|
|||
* `-r`, `--revision <REVISION>` — The revision to touch up
|
||||
|
||||
Defaults to @ if neither --to nor --from are specified.
|
||||
* `--from <FROM>` — Show changes from this revision
|
||||
* `-f`, `--from <FROM>` — Show changes from this revision
|
||||
|
||||
Defaults to @ if --to is specified.
|
||||
* `--to <TO>` — Edit changes in this revision
|
||||
* `-t`, `--to <TO>` — Edit changes in this revision
|
||||
|
||||
Defaults to @ if --from is specified.
|
||||
* `--tool <NAME>` — Specify diff editor to be used
|
||||
|
@ -1316,8 +1317,8 @@ This excludes changes from other commits by temporarily rebasing `--from` onto `
|
|||
|
||||
###### **Options:**
|
||||
|
||||
* `--from <FROM>` — Show changes from this revision
|
||||
* `--to <TO>` — Show changes to this revision
|
||||
* `-f`, `--from <FROM>` — Show changes from this revision
|
||||
* `-t`, `--to <TO>` — Show changes to this revision
|
||||
* `-s`, `--summary` — For each path, show only whether it was modified, added, or deleted
|
||||
* `--stat` — Show a histogram of the changes
|
||||
* `--types` — For each path, show only its type before and after
|
||||
|
@ -1510,8 +1511,8 @@ Compare changes to the repository between two operations
|
|||
###### **Options:**
|
||||
|
||||
* `--operation <OPERATION>` — Show repository changes in this operation, compared to its parent
|
||||
* `--from <FROM>` — Show repository changes from this operation
|
||||
* `--to <TO>` — Show repository changes to this operation
|
||||
* `-f`, `--from <FROM>` — Show repository changes from this operation
|
||||
* `-t`, `--to <TO>` — Show repository changes to this operation
|
||||
* `--no-graph` — Don't show the graph, show a flat list of modified changes
|
||||
* `-p`, `--patch` — Show patch of modifications to changes
|
||||
|
||||
|
@ -1913,8 +1914,8 @@ See `jj diffedit` if you'd like to restore portions of files rather than entire
|
|||
|
||||
###### **Options:**
|
||||
|
||||
* `--from <FROM>` — Revision to restore from (source)
|
||||
* `--to <TO>` — Revision to restore into (destination)
|
||||
* `-f`, `--from <FROM>` — Revision to restore from (source)
|
||||
* `-t`, `--to <TO>` — Revision to restore into (destination)
|
||||
* `-c`, `--changes-in <REVISION>` — Undo the changes in a revision as compared to the merge of its parents.
|
||||
|
||||
This undoes the changes that can be seen with `jj diff -r REVISION`. If `REVISION` only has a single parent, this option is equivalent to `jj restore --to REVISION --from REVISION-`.
|
||||
|
|
|
@ -642,15 +642,15 @@ fn test_help() {
|
|||
let test_env = TestEnvironment::default();
|
||||
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["diffedit", "-h"]);
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
insta::assert_snapshot!(stdout, @r"
|
||||
Touch up the content changes in a revision with a diff editor
|
||||
|
||||
Usage: jj diffedit [OPTIONS]
|
||||
|
||||
Options:
|
||||
-r, --revision <REVISION> The revision to touch up
|
||||
--from <FROM> Show changes from this revision
|
||||
--to <TO> Edit changes in this revision
|
||||
-f, --from <FROM> Show changes from this revision
|
||||
-t, --to <TO> Edit changes in this revision
|
||||
--tool <NAME> Specify diff editor to be used
|
||||
--restore-descendants Preserve the content (not the diff) when rebasing descendants
|
||||
-h, --help Print help (see more with '--help')
|
||||
|
@ -665,7 +665,7 @@ fn test_help() {
|
|||
--quiet Silence non-primary command output
|
||||
--no-pager Disable the pager
|
||||
--config-toml <TOML> Additional configuration options (can be repeated)
|
||||
"#);
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue