cli:converge: new jj converge command - #9802
Merged
Merged
Conversation
Merged
6 tasks
josephlou5
reviewed
Jul 11, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
from
July 13, 2026 16:00
495c622 to
56c2d43
Compare
mirkomartn
reviewed
Jul 13, 2026
mirkomartn
reviewed
Jul 14, 2026
mirkomartn
left a comment
Contributor
There was a problem hiding this comment.
I'm definitely out of my depth here, so apologies for any dumb questions.
drieber
force-pushed
the
push-nuzsrntnyktx
branch
3 times, most recently
from
July 17, 2026 17:46
862d19e to
f668d14
Compare
algmyr
reviewed
Jul 18, 2026
algmyr
reviewed
Jul 18, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
8 times, most recently
from
July 20, 2026 22:44
ab44dd2 to
d2c3861
Compare
This comment was marked as outdated.
This comment was marked as outdated.
drieber
force-pushed
the
push-nuzsrntnyktx
branch
3 times, most recently
from
July 21, 2026 00:50
50d468b to
82cfff1
Compare
This comment was marked as outdated.
This comment was marked as outdated.
josephlou5
reviewed
Jul 21, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
3 times, most recently
from
July 21, 2026 21:35
5ce972b to
8b1bd9a
Compare
josephlou5
reviewed
Jul 21, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
from
July 21, 2026 22:23
8b1bd9a to
1cb24dd
Compare
drieber
force-pushed
the
push-nuzsrntnyktx
branch
from
August 16, 2026 16:54
b8164f2 to
515bc1f
Compare
martinvonz
reviewed
Aug 17, 2026
martinvonz
reviewed
Aug 18, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
8 times, most recently
from
August 18, 2026 01:50
dcd9bb3 to
3c17e88
Compare
…r commit
Why this change?
----------------
When the heuristics used by converge_change cannot come up with a description,
author and/or parents for the solution, it produces ConvergedAttribute::unsolved.
The heuristics use dominator value algorithm to create a Merge<V> --a merge of
values, e.g. a Merge<String> for descriptions or Merge<Vec<CommitId>> for
parents. The heuristics fail when the Merge<V> does not resolve trivially.
ConvergedAttribute::unsolved includes the CommitId of the "base commit". The base
commit is "a" commit in the evolution history that "has" the dominator value. In
converge.rs we call this a "value producer". For example the description merge
may be:
```
Merge(add: "bar", remove: "foo", add: "baz").
```
That merge does not resolve trivially. The "base commit" is a commit in the
truncated evolution graph that has description "foo". It is guaranteed that
such a commit exists, but there could be more than one. The changes here affect
how that choice is made. converge_change MUST choose deterministically, and
should try to make a decent choice.
Where is ConvergeAttribute::unsolved.base_commit used? A follow up change in this
sequence introduces the `jj converge` command. That command uses the base_commit
when asking the user to merge divergent commit descriptions: it presents the user
with an editor with the conflicting descriptions with conflict markers and
conflict labels. The conflict label marker for the base description is the
conflict labels of the base commit.
There is another place where the "base commit" is used: in conflict markers in
the MergedTree of the solution commit.
What is the change?
-------------------
Previously commit timestamp was not considered at all when choosing a base commit
among two or more value producers. Now commit timestamp is considered. A commit
with a more recent timestamp is given preference over a commit with an older
timestamp. Why not simply use change offset ordering? The algorithm DOES use
change ordering when choosing the base commit, but on some backends not all
commits for a given change-id have change offsets. For example at Google
change offset is calculated only for some commits (I forget the details, I
think it is only for visible commits or something like that).
drieber
force-pushed
the
push-nuzsrntnyktx
branch
2 times, most recently
from
August 18, 2026 03:27
f360811 to
044f710
Compare
The motivation is to make the return type more appropriate for use in the converge command. Before this commit: ``` CommitsByChangeId = HashMap<ChangeId, HashMap<CommitId, Commit>> ``` After this commit: ``` CommitsByChangeId = BTreeMap<ChangeId, Vec<Commit>> ``` The change-ids are now sorted. Also, the commits for a given (divergent) change-id are now sorted by revset-engine order.
drieber
force-pushed
the
push-nuzsrntnyktx
branch
2 times, most recently
from
August 18, 2026 03:56
42e1bc3 to
c0779d9
Compare
martinvonz
reviewed
Aug 18, 2026
drieber
force-pushed
the
push-nuzsrntnyktx
branch
4 times, most recently
from
August 19, 2026 00:22
5776cf7 to
9251ab0
Compare
`jj converge` allows users to "fix" divergence. The command tries to create a new commit for the divergent change that rewrites all divergent commits. The command tries to do this automatically, but falls back to prompting the user for pieces of information as needed. The command uses the lib/converge.rs library to do most of the work. The command takes an optional --search_space revset (it looks for divergent commits matching that revset). If not specified the command uses a new `revsets.converge` system revset (mutable() & divergent()). If the command cannot automatically merge the descriptions, the user's text editor is invoked to let the user merge the divergent descriptions manually (as if they were conflicts on a "description" file). The command has a --interactive=true/false flag to allow users to invoke it without prompting the user.
drieber
force-pushed
the
push-nuzsrntnyktx
branch
from
August 19, 2026 00:40
9251ab0 to
59ac566
Compare
martinvonz
approved these changes
Aug 19, 2026
martinvonz
left a comment
Contributor
There was a problem hiding this comment.
Thanks! This looks good to me. I'm sure we'll discover things to polish, but that can be done later. Hearing from users will be valuable.
Contributor
Author
Thank you for the review! I know this was a large PR, I appreciate all the feedback I got. I already have some ideas of what could be improved here, and most importantly I hope to get user feedback. For now I have #10009 to mention jj converge in docs/guides/divergence.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.