Improve the documentation of jj prev

This will hopefully make it clear that `jj prev` does not
move by [OFFSET] relative to `@`, which is a misconception
that I had and I think others may also have.

I am suggesting this change as a result of the vigorous discussion in
these two issues:

- https://github.com/martinvonz/jj/issues/3426
- https://github.com/martinvonz/jj/pull/3445

We should make similar changes to `jj next` as well since
it follows similar rules.
This commit is contained in:
Evan Mesterhazy 2024-04-04 13:04:49 -04:00 committed by Evan Mesterhazy
parent 73508730aa
commit c1920d765f
2 changed files with 43 additions and 40 deletions

View file

@ -20,35 +20,36 @@ use crate::cli_util::{short_commit_hash, CommandHelper};
use crate::command_error::{user_error, CommandError}; use crate::command_error::{user_error, CommandError};
use crate::commands::next::choose_commit; use crate::commands::next::choose_commit;
use crate::ui::Ui; use crate::ui::Ui;
/// Change the working copy revision relative to the parent revision
/// Move the working-copy commit to the parent revision
/// ///
/// The command creates a new empty working copy revision that is the child of
/// an ancestor `offset` revisions behind the parent of the current working
/// copy.
/// ///
/// The command moves you to the parent in a linear fashion. /// For example, when the offset is 1:
/// ///
/// ```text /// ```text
/// D @ D /// D @ D
/// |/ | /// |/ |
/// A => A @ /// A => A @
/// | |/ /// | |/
/// B B /// B B
/// ``` /// ```
/// ///
/// If `--edit` is passed, it will move the working copy commit /// If `--edit` is passed, the working copy revision is changed to the parent of
/// directly to the parent. /// the current working copy revision.
/// ///
/// ```text /// ```text
/// D @ D /// D @ D
/// |/ | /// |/ |
/// C => @ /// C => @
/// | | /// | |
/// B B /// B B
/// | | /// | |
/// A A /// A A
/// /// ```
/// If your working-copy commit already has visible children, then `--edit` is /// If the working copy revision already has visible children, then `--edit` is
/// implied. /// implied.
/// ```
// TODO(#2126): Handle multiple parents, e.g merges. // TODO(#2126): Handle multiple parents, e.g merges.
#[derive(clap::Args, Clone, Debug)] #[derive(clap::Args, Clone, Debug)]
#[command(verbatim_doc_comment)] #[command(verbatim_doc_comment)]

View file

@ -128,7 +128,7 @@ To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/d
* `obslog` — Show how a change has evolved * `obslog` — Show how a change has evolved
* `operation` — Commands for working with the operation log * `operation` — Commands for working with the operation log
* `parallelize` — Parallelize revisions by making them siblings * `parallelize` — Parallelize revisions by making them siblings
* `prev` — Move the working-copy commit to the parent revision * `prev` — Change the working copy revision relative to the parent revision
* `rebase` — Move revisions to different parent(s) * `rebase` — Move revisions to different parent(s)
* `resolve` — Resolve a conflicted file with an external merge tool * `resolve` — Resolve a conflicted file with an external merge tool
* `restore` — Restore paths from another revision * `restore` — Restore paths from another revision
@ -1385,34 +1385,36 @@ several conditions, otherwise the command will fail.
## `jj prev` ## `jj prev`
Move the working-copy commit to the parent revision Change the working copy revision relative to the parent revision
The command creates a new empty working copy revision that is the child of
an ancestor `offset` revisions behind the parent of the current working
copy.
The command moves you to the parent in a linear fashion. For example, when the offset is 1:
```text ```text
D @ D D @ D
|/ | |/ |
A => A @ A => A @
| |/ | |/
B B B B
``` ```
If `--edit` is passed, it will move the working copy commit If `--edit` is passed, the working copy revision is changed to the parent of
directly to the parent. the current working copy revision.
```text ```text
D @ D D @ D
|/ | |/ |
C => @ C => @
| | | |
B B B B
| | | |
A A A A
```
If your working-copy commit already has visible children, then `--edit` is If the working copy revision already has visible children, then `--edit` is
implied. implied.
```
**Usage:** `jj prev [OPTIONS] [OFFSET]` **Usage:** `jj prev [OPTIONS] [OFFSET]`