Pulling the Rug Out Under Oneself
Here's the situation:
$ jj edit x
@ vz empty
├─╮
│ ○ o Play instructions
│ ○ kx Play manual
○ │ zx Click alternates Xs and Os main
○ │ v Click sets a X
○ │ s Square has state
├─╯
○ n Square is interactive
○ ru Board() invokes Square()
You want to abandon the merge Change vz, which coincidentally, is
also the Current Change:
$ jj abandon -r vz
@ x empty
├─╮
│ ○ o Play instructions
│ ○ kx Play manual
○ │ zx Click alternates Xs and Os main
○ │ v Click sets a X
○ │ s Square has state
├─╯
○ n Square is interactive
○ ru Board() invokes Square()
Uh! That was unexpected! The merge is still there! And with a different Change ID. Why is that?
This is what Jujutsu thinks:
- User asked me to abandon the merge commit. At once! Deleted!
- Uhm. That Change was the Current Change the user was editing. Of course I cannot leave the user orphaned. I need to create a Change for them!
- How and where shall I create it? I was given no instructions. I will create one as similar as possible as the deleted one: same position, which means, same parents.
So, another merge is generated.
This also happens in general: you can abandon your Current Change, but this will be immediately replaced by a new one.
When Jujutsu Deletes Changes Without Any Advice
There's more. Look what happens if you move somewhere else:
$ jj edit n
○ o Play instructions
○ kx Play manual
│ ○ zx Click alternates Xs and Os main
│ ○ v Click sets a X
│ ○ sn Square has state
├─╯
@ n Square is interactive
~
Woop! Jujutsu evaluated that the newly created merge Change was completely unused: not only was it empty, it was also messageless. Therefore, as you moved await from it, it abandoned it.
It's The Right Thing To Do
This might seem odd at first, but it's actually an astute design choice: Jujutsu tracks only what you explicitly scoped, preventing your repository from being cluttered with empty, unnecessary Changes.
Try this: target any Change in your tree history and visit it using
jj new, instead of jj edit:
$ jj new n
@ m empty
│ ○ o Play instructions
│ ○ kx Play manual
├─╯
│ ○ zx Click alternates Xs and Os main
│ ○ v Click sets a X
│ ○ s Square has state
├─╯
○ n Square is interactive
○ ru Board() invokes Square()
├─╮
○ │ ym fix name: Square -> Board
○ │ x WIP delete me
○ │ yz LICENSE
○ │ ws A board full of X
├─╯
○ kk Displays X X
○ wx Fails
○ rx Scaffold applicatio
◆ zz 🔒 empty
~
Jujutsu created a Change m, as a child of n. Move somewhere
else:
$ jj new rx
@ sy empty
│ ○ zx Click alternates Xs and Os main
│ ○ v Click sets a X
│ ○ sn Square has state
│ │ ○ o Play instructions
│ │ ○ kx Play manual
│ ├─╯
│ ○ n Square is interactive
│ ○ ru Board() invokes Square()
│ ├─╮
│ ○ │ ym fix name: Square -> Board
│ ○ │ x WIP delete me
│ ○ │ yz LICENSE
│ ○ │ ws A board full of X
│ ├─╯
│ ○ kk Displays X X
│ ○ wx Fails
├─╯
○ rx Scaffold applicatio
◆ zz 🔒 empty
Voilà, you are in a new Change on top of rx. And the previous
Change has been cleaned up.