Commit graph

1749 commits

Author SHA1 Message Date
Yuya Nishihara
6dfc9de9b4 cli: evolog: show associated operations alongside commits
The output cannot be templated as of now. Maybe we can add a template type for
Commit + Operation?

Closes #963
2025-05-27 13:28:09 +00:00
Yuya Nishihara
60f8bdda7a evolution: walk operations to build predecessors graph
This is slower than traversing commit.predecessor_ids, but allows us to show
associated operations alongside the commits. Since operations are (mostly)
traversed in chronological order, the evolution graph is also emitted in that
order.
2025-05-27 13:28:09 +00:00
Eyvind Bernhardsen
86f45b233b show: Accept short forms of ignore-space options
Make `jj show` accept the same short forms, `-b` and `-w`, as `jj diff`
for the `--ignore-space-change` and `--ignore-all-space` options.
2025-05-26 15:55:25 +00:00
Yuya Nishihara
9612347497 op_store: load/store commit predecessors
Operation ids in test_op_abandon*() are changed because reparented operations
now preserve the predecessors mapping.

Since this patch will affect whether "jj evolog" can show the associated
operations, I added a changelog entry. It's still a bit vague, but I think we
can add a more detailed explanation later.
2025-05-26 10:23:29 +00:00
Yuya Nishihara
42a2a2dd95 repo: store commit predecessors in Operation object
There are two major goals:
1. garbage-collect predecessor commits referenced by immutable commits.
2. show operations alongside predecessors in "jj evolog".

The predecessors field will be removed from the Commit object. Maybe we can
also remove (writer side of) the extras table from GitBackend.

"jj evolog" will traverse the operation history to build an evolution
graph. This will be slower than the current implementation, but it seems
tolerable for mid-size repository stored in a local disk.

    (when the page cache is warm)
    % time jj op log -T'"."' --no-graph | wc -c
    50459
    jj op log -T'"."' --no-graph  0.12s user 0.31s system 103% cpu 0.418 total

Suppose we're interested in recent modifications, the traversal can often be
terminate early. I also have an idea for indexing originating operations.
https://github.com/jj-vcs/jj/pull/6405

For old operations which didn't record predecessors, "jj evolog" will fall back
to commit.predecessor_ids(). That's why commit_predecessors is Option<_>.
2025-05-26 10:23:29 +00:00
Bryce Berger
e2ab700f2c parallelize: only check to-be-rewritten commits for rewritability
closes #6587

Given a commit history like this:
    ○  ccc
    ○  bbb
    ◆  aaa

Parallelize *should* be able to create this:
    ○  ccc
    │ ○  bbb
    ├─╯
    │ ◆  aaa
    ├─╯

This is fine because `aaa` will not be rewritten --- its children will,
but neither `aaa`'s parents nor author information needs to be changed.

However, the current implementation checks _all_ commits in the
target set for rewritability, instead of only the commits that will
be rewritten.

This commit changes that. Now, only the commits whose parents *will*
change are checked for rewritability.
2025-05-23 21:22:41 +00:00
Vincent Ging Ho Yim
11b1c502f0 test: replace cfg! macro with cfg_attr attribute
Using the `cfg_attr` attribute means the test is still compiled on non-macOS
architectures and checked but is ignored and not run, instead of running and passing.
2025-05-22 23:25:01 +00:00
Vincent Ging Ho Yim
f1765183d6 cli: use more precise wording in conflict resolution hint
We already use "conflicted commit" at the very end of the hint, so I've reused that term
here.
2025-05-22 03:49:34 +00:00
Vincent Ging Ho Yim
365f26fe58 cli util completion: remove deprecated arguments for each shell
The optional arguments for each shell were deprecated in #2945 and v0.19.0.

The `shell` argument is now required, and Bash completions are no longer generated by
default if `jj util completion` is run without any arguments.
2025-05-22 02:51:51 +00:00
Vincent Ging Ho Yim
f4913512e2 cli util completion: add link to docs in doc comment 2025-05-22 02:51:51 +00:00
Vincent Ging Ho Yim
6ff4f45d78 test: clean up config strings 2025-05-22 00:13:27 +00:00
Vincent Ging Ho Yim
96e73bdadd cli undo: detect "double undo" from operation metadata instead
To identify an `undo` operation, checking that the views of the "bad" op and its
grandparent are equal is necessary but not sufficient. For example, creating a bookmark
and then immediately deleting it also "resets" the view. This commit fixes this by also
checking the "description" in the operation metadata to identify "double undo" properly.

With this commit, the "double undo" warning is now shown whether users undid the latest
undo implicitly (with `jj (op) undo`) or explicitly (with `jj (op) undo <op set>` or `jj
(op) undo @`).

If undoing an older undo (prior to `@`), the warning is not shown.
2025-05-21 13:20:10 +00:00
Vincent Ging Ho Yim
ca7a6fcbce test: add more undo tests
- Undoing latest undo explicitly with `jj undo @`.
- Undoing an older undo (that is not the most recent operation).
- Undoing an undo multiple times.
- Undoing a bookmark deletion (a spurious "double undo" warning is shown).
2025-05-21 13:20:10 +00:00
Vincent Ging Ho Yim
ab6473d282 test: rename some undo tests to avoid specifying current behavior
The test snapshots serve to indicate point-in-time behavior, so we shouldn't encode the
behavior in the test names. A later commit will change the current behavior so that
undoing the latest undo explicitly by op id or with the `@` symbol will no longer differ
in whether a warning is shown.

Incidentally, there is currently no difference in behavior between `jj undo` ("bare
undo") and `jj op undo`, as the former simply shells out to the latter.
2025-05-21 13:20:10 +00:00
Vincent Ging Ho Yim
7fffa36b8e cli undo: upgrade first part of "double undo" hint to a warning, clarify repo state
A warning alerts users to a situation they may not have expected, which applies here.

The warning now explicitly calls out which `undo` has been reverted by which `undo`.
Also made the following hint more concise.
2025-05-21 13:20:10 +00:00
Vincent Ging Ho Yim
33e551db29 test: add tests for undoing root and merge operations 2025-05-21 13:20:10 +00:00
Scott Taylor
0666781d80 rebase: print summary of abandoned duplicate divergent commits
This is more consistent with `jj abandon`. I also changed the wording
from "skipped" to "abandoned" to make it more clear.
2025-05-21 12:12:41 +00:00
Scott Taylor
4eabf9a511 rebase: abandon commits while rebasing
This fixes a bug where the rebase wouldn't work properly if a root of
the target commit set was abandoned before being rebased.
2025-05-21 11:58:13 +00:00
Scott Taylor
6b9e944cd0 rebase: demo bug with skipping divergent commits
If the root of the target commit set is abandoned, it prevents the
commits from being rebased properly.
2025-05-21 11:58:13 +00:00
Winter
2d1f50a8ea cli: resolve: show a hint towards editing the conflict markers manually if the conflict has >2 sides
As suggested in Discord: https://discord.com/channels/968932220549103686/1370632916169920523
2025-05-20 18:11:43 +00:00
Scott Taylor
c406b3a929 rebase: skip duplicate divergent commits by default
This serves a similar purpose to Git's patch ID mechanism, however it is
slightly different in that it only compares commits which have the same
change ID as each other (divergent changes), and it does a full
comparison of the commits to see if they would have identical trees if
rebased onto the same parents. Since most changes aren't divergent, I
believe this should have a negligible performance cost in most cases.

I think skipping these commits by default makes sense for `jj rebase`,
since usually this will be a helpful behavior for the user. With this
behavior, a safe first step when encountering divergent changes would be
to rebase one branch on top of the other, since that will abandon any
divergent changes that have identical contents to existing commits,
leaving behind any non-trivial divergent changes for the user to resolve
manually.
2025-05-19 22:23:32 +00:00
Vincent Ging Ho Yim
855fe12faf test: migrate remaining jj branch uses to jj bookmark 2025-05-19 13:20:20 +00:00
Vincent Ging Ho Yim
db37450ef2 cli: sort top-level commands lexicographically
The Markdown docs have been regenerated as well.
2025-05-19 12:11:57 +00:00
Yuya Nishihara
8cd32b20a3 cli: config edit: show file path to edit
I think the file path is generally useful, and isn't verbose. Just print it
unconditionally.

Closes #6566
2025-05-19 10:47:01 +00:00
Yuya Nishihara
6df3e240ed cli: add top-level context label to commit templates
Since operation templates have "operation" label, commit templates should have
"commit" for consistency.

The [colors] table is not updated to use the "commit" prefix. There are some
non-template outputs which use unqualified "bookmark"/"tag"/"git_ref" labels.
That's also a reason why "bookmark_list" template doesn't have a "bookmark"
context label yet. (We'll need to qualify the color definition as "commit
bookmark" so the whole bookmark list wouldn't be colorized as "bookmark".)
2025-05-19 01:41:15 +00:00
Yuya Nishihara
28cb16e83e cli: add top-level command-name label to op diff/show templates 2025-05-19 01:41:15 +00:00
Yuya Nishihara
d43d8c4e23 cli: add top-level command-name/context labels to graph "node" templates
It's inconsistent that the content templates have e.g. "op_log operation", but
the graph node templates don't.
2025-05-19 01:41:15 +00:00
Yuya Nishihara
86d4f4b90f cli: git: do not attempt to align bookmark and tag changes in stats
It was broken when we renamed "branch" to "bookmark", and there were no
complaints since then. Let's simply align changes per ref type.
2025-05-18 07:30:46 +00:00
Yuya Nishihara
a1abe46c45 cli: define "operation tags" color properly
It's unrelated to (commit) "tags", and the color of "current_operation" seemed
wrong.
2025-05-18 01:42:14 +00:00
Yuya Nishihara
183a7b6eba cli: label "working_copy" by commit_summary template, not by code
I'm thinking of adding a top-level context label consistently. If we added
"commit" to the summary template (in code), the status output would be labeled
as "working_copy commit ..", whereas log entries would be labeled as "commit
working_copy ..". The latter should be more correct since the "commit" label
is global.

Now the working-copy entry is highlighted in op log and bookmark list, which
I think is good.
2025-05-18 01:42:14 +00:00
Yuya Nishihara
f7f85383bc tests: snapshot a few more colored outputs 2025-05-18 01:42:14 +00:00
Vincent Ging Ho Yim
e18eb8e05e test: clean up op log output to show short op ids 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
9d995c7f43 test: use --at-op and templates instead of manually parsing op ids from op log
There is an additional run of `jj op log`, so a commit id has changed here.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1398f1c174 test: rename op id variables and reword comment
The `previous_op_id` doesn't belong to the operation immediately before the
`current_op_id`. There is one operation in between, namely the latest snapshot taken.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
2a596f7516 test: remove redundant --at-op argument 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
3dcf2e4d75 test: refactor to use get_log_output() helper function 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1636202413 test: omit commit ids from log template
We are not interested in the commit ids here.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1447ff8f25 test: fix grammar in comment 2025-05-17 12:20:38 +00:00
Isaac Corbrey
85d54eb3d8 docs: Don't include unnecessary shebangs
It isn't necessary to include shebangs in scripts passed into
`util exec` since you're already explicitly calling out the shell you'd
like to use. This change removes shebangs from examples for `util exec`
and adds a note below calling this out.
2025-05-17 11:51:07 +00:00
Yuya Nishihara
88d79c135b cli: accept --tool=:<format> argument as builtin diff format
This is just for completeness. I don't think this is practically useful, but the
:<format> syntax should work in both config files and command arguments.
2025-05-17 00:11:00 +00:00
Nicole Patricia Mazzuca
f9d59a36c0 config: clarify warning
Instead of saying to move configuration files from
`~/Library/Application Support` to `~/.config`, jj now tells you to move
configuration files from `~/Library/Application Support/jj` to
`~/.config/jj`.
2025-05-16 13:46:22 +00:00
T6
13c6257aac templater: add arithmetic operators 2025-05-16 12:45:09 +00:00
Yuya Nishihara
e9600ccfdb templater: split ChangeId/CommitId types
This isn't complex compared to the enum version, and provides a better error
message.
2025-05-16 11:12:33 +00:00
Gaëtan Lehmann
0b0d313583 split: use "selected/remaining changes" instead of "first/second commits"
With the new -A/-B/-d flags, the new commit may be created anywhere in
the tree, making the denomination first/second commit inaccurate.
2025-05-16 07:55:12 +00:00
Vincent Ging Ho Yim
20fd0b7daf cli bookmark move: move names argument before --from argument
The usage line originally showed `--from <REVSETS>|NAMES`, which was confusing as it
could be parsed as `--from (<REVSETS> or NAMES)`, rather than the correct `(--from
<REVSETS>) or NAMES`.

The order of the two arguments are now swapped, so that Clap displays it as
`NAMES|--from <REVSETS>` instead. Using bookmark names as the move targets should be
more common anyway. This is also consistent with the order in which the two arguments
are described in the command's doc comment.
2025-05-16 05:06:15 +00:00
Yuya Nishihara
851d25cd68 cli: unify diff format/tool config variables
This allows users to override the external tool set in ~/.jjconfig.toml. The
config variable is renamed to ui.diff-formatter to be consistent with the other
diff/merge editor settings.

--tool=:<format> support will be added separately.

Closes #3327
2025-05-16 00:33:49 +00:00
Vincent Ging Ho Yim
b99116fc23 cli: improve hint to abandon commits when divergent change appears
A divergent change could point to more than two commits, so the hint now suggests
abandoning unneeded commits rather than just one of them.

The `-r` flag is unnecessary for `jj abandon` as it is implied.

Also changed `<REVISION>` to `<commit_id>` to be clear that using the change id here
will not work.
2025-05-16 00:21:38 +00:00
Vincent Ging Ho Yim
cfce146f8f commit: show a hint if --message is not provided and the description is empty
This addresses part of #4414 and implements something akin to what's described in
@arxanas's [suggestion], with the exception that the editor contents don’t need to be
completely cleared, since whether cleared or not it is not obvious whether the user
intended to add an empty description or abort entirely.

[suggestion]: https://github.com/jj-vcs/jj/issues/4414#issuecomment-2359123535

The hint is not shown if an empty description is provided via `--message ""`, since the
user is explicitly bypassing the editor and wants to commit the change directly.

Otherwise, if a user exits the editor with an empty description (notwithstanding any
`JJ:` lines), it could be one of the following cases:

1. The user wants to commit the changes but no longer wants to add a description. The
hint can simply be ignored.

2. The user wants to commit the changes and add a description but accidentally exits the
editor. The second hint shows how to add a description to the parent commit.

3. The user no longer wants to commit the changes. However, a new commit is still
created to maintain consistent behaviour as when an empty description is provided via
the CLI. The first hint shows how to undo the commit.
2025-05-15 13:02:53 +00:00
Vincent Ging Ho Yim
c683756533 commit: add tests for committing with empty description from CLI and from editor 2025-05-15 13:02:53 +00:00
Vincent Ging Ho Yim
9a39bf6c41 commit: remove trailing whitespace 2025-05-15 13:02:53 +00:00