A Glimpse of the Revset Language
Important
You learn to describe sets of Changes, and how
rebasecouldn’t care less about their position.
With Git, you typically rebase entire branches. Jujutsu’s rebase
makes no assumptions about what you want to move.
You saw how to move a single Change. You can just as easily move multiple Changes, by specifying them:
jj rebase -r X -r Y -o O
This moves both X and Y onto O. It doesn’t matter where they
are: they can even be sparse!
Instead of listing Changes one by one, use the Revset Language. Here’s a taste:
| Notation | Meaning |
|---|---|
X | Y | Changes in set X plus Changes in set Y. |
X & Y | Changes in both X and Y. |
~X | Changes not in X. |
X:: | X and all its descendants. |
::X | X and all its ancestors. |
X::Y | All Changes between X and Y, included. |
X and Y don’t have to be single Changes; they can be sets
themselves. Each expression returns a set, and you can recursively
combine them. This expressiveness, along with custom functions, makes
Revsets immensely more powerful than Git’s revspecs.
Moving Sets of Changes
Here’s a silly exercise: can you move sparse Changes too? Sure, why
not! In fact, rebase works with whatever set of Changes you pass
it.
Say that for some (odd) reason you want to move v, and yz on top
of rt:
m ▢
○ qn Add the CSS file **css***
○ rt Link to CSS <-- here
│ ○ o Play instructions **manual***
│ ○ kx Play manual
├─╯
│ ○ zx Click alternates Xs and Os **dev***
│ ○ v Click sets a X <-- v
│ ○ s Square has state
├─╯
○ qq Fix
○ n Square is interactive
○ ru Board() invokes Square()
├─╮
○ │ ym fix name: Square -> Board
○ │ ws A board full of X
├─╯
○ kk Displays X X **main***
○ wx Fails
○ rx Scaffold application
○ yz LICENSE <-- yz
◆ zz 🔒 ▢
Warning
How would you do that in one shot?
Tip
Using a revset expression:
jj rebase -r 'yz | v' -o rt@ m ▢ ○ qn Add the CSS file css* │ ○ v Click sets a X <-- v │ ○ yz LICENSE <-- yz ├─╯ ○ rt Link to CSS <-- new base │ ○ o Play instructions manual* │ ○ kx Play manual ├─╯ ~
Before the next page, undo that move:
jj undo
Feel free to spend some time moving sets of Changes around. Then pause and think how you’d do the same move in Git. it will always be technically possible just rarely this straightforward.