2021-12-14 05:46:42 +00:00
|
|
|
|
# Revsets
|
|
|
|
|
|
|
|
|
|
Jujutsu supports a functional language for selecting a set of revisions.
|
|
|
|
|
Expressions in this language are called "revsets" (the idea comes from
|
|
|
|
|
[Mercurial](https://www.mercurial-scm.org/repo/hg/help/revsets)). The language
|
|
|
|
|
consists of symbols, operators, and functions.
|
|
|
|
|
|
|
|
|
|
Most `jj` commands accept a revset (or multiple). Many commands, such as
|
|
|
|
|
`jj diff -r <revset>` expect the revset to resolve to a single commit; it is
|
|
|
|
|
an error to pass a revset that resolves to more than one commit (or zero
|
|
|
|
|
commits) to such commands.
|
|
|
|
|
|
|
|
|
|
The words "revisions" and "commits" are used interchangeably in this document.
|
|
|
|
|
|
2023-11-01 02:41:03 +00:00
|
|
|
|
Most revsets search only the [visible commits](glossary.md#visible-commits).
|
2021-12-14 05:46:42 +00:00
|
|
|
|
Other commits are only included if you explicitly mention them (e.g. by commit
|
|
|
|
|
ID or a Git ref pointing to them).
|
|
|
|
|
|
|
|
|
|
## Symbols
|
|
|
|
|
|
2023-09-03 04:41:15 +00:00
|
|
|
|
The `@` expression refers to the working copy commit in the current workspace.
|
|
|
|
|
Use `<workspace name>@` to refer to the working-copy commit in another
|
2024-09-11 16:11:50 +00:00
|
|
|
|
workspace. Use `<name>@<remote>` to refer to a remote-tracking bookmark.
|
2021-12-14 05:46:42 +00:00
|
|
|
|
|
|
|
|
|
A full commit ID refers to a single commit. A unique prefix of the full commit
|
|
|
|
|
ID can also be used. It is an error to use a non-unique prefix.
|
|
|
|
|
|
|
|
|
|
A full change ID refers to all visible commits with that change ID (there is
|
|
|
|
|
typically only one visible commit with a given change ID). A unique prefix of
|
|
|
|
|
the full change ID can also be used. It is an error to use a non-unique prefix.
|
|
|
|
|
|
2024-04-17 12:17:40 +00:00
|
|
|
|
Use [single or double quotes][string-literals] to prevent a symbol from being
|
|
|
|
|
interpreted as an expression. For example, `"x-"` is the symbol `x-`, not the
|
|
|
|
|
parents of symbol `x`. Taking shell quoting into account, you may need to use
|
|
|
|
|
something like `jj log -r '"x-"'`.
|
|
|
|
|
|
|
|
|
|
[string-literals]: templates.md#string-literals
|
2021-12-14 05:46:42 +00:00
|
|
|
|
|
|
|
|
|
### Priority
|
|
|
|
|
|
|
|
|
|
Jujutsu attempts to resolve a symbol in the following order:
|
|
|
|
|
|
2023-09-03 03:47:23 +00:00
|
|
|
|
1. Tag name
|
2024-09-11 16:11:50 +00:00
|
|
|
|
2. Bookmark name
|
2023-09-03 03:47:23 +00:00
|
|
|
|
3. Git ref
|
|
|
|
|
4. Commit ID or change ID
|
2021-12-14 05:46:42 +00:00
|
|
|
|
|
|
|
|
|
## Operators
|
|
|
|
|
|
|
|
|
|
The following operators are supported. `x` and `y` below can be any revset, not
|
|
|
|
|
only symbols.
|
|
|
|
|
|
2024-06-06 07:34:38 +00:00
|
|
|
|
* `x-`: Parents of `x`, can be empty.
|
|
|
|
|
* `x+`: Children of `x`, can be empty.
|
2024-06-16 21:48:02 +00:00
|
|
|
|
* `x::`: Descendants of `x`, including the commits in `x` itself. Shorthand for
|
|
|
|
|
`x::visible_heads()`.
|
|
|
|
|
* `x..`: Revisions that are not ancestors of `x`. Shorthand for
|
|
|
|
|
`x..visible_heads()`.
|
|
|
|
|
* `::x`: Ancestors of `x`, including the commits in `x` itself. Shorthand for
|
|
|
|
|
`root()::x`.
|
2024-06-06 07:19:26 +00:00
|
|
|
|
* `..x`: Ancestors of `x`, including the commits in `x` itself, but excluding
|
2024-06-16 21:48:02 +00:00
|
|
|
|
the root commit. Shorthand for `root()..x`. Equivalent to `::x ~ root()`.
|
2023-09-05 21:58:13 +00:00
|
|
|
|
* `x::y`: Descendants of `x` that are also ancestors of `y`. Equivalent
|
|
|
|
|
to `x:: & ::y`. This is what `git log` calls `--ancestry-path x..y`.
|
2023-05-05 17:29:56 +00:00
|
|
|
|
* `x..y`: Ancestors of `y` that are not also ancestors of `x`. Equivalent to
|
2023-09-05 21:58:13 +00:00
|
|
|
|
`::y ~ ::x`. This is what `git log` calls `x..y` (i.e. the same as we call it).
|
2024-06-16 21:48:02 +00:00
|
|
|
|
* `::`: All visible commits in the repo. Shorthand for
|
|
|
|
|
`root()::visible_heads()`. Equivalent to `all()`.
|
2023-09-03 08:08:16 +00:00
|
|
|
|
* `..`: All visible commits in the repo, but excluding the root commit.
|
2024-06-16 21:48:02 +00:00
|
|
|
|
Shorthand for `root()..visible_heads()`. Equivalent to `~root()`.
|
2024-06-06 07:19:26 +00:00
|
|
|
|
* `~x`: Revisions that are not in `x`.
|
|
|
|
|
* `x & y`: Revisions that are in both `x` and `y`.
|
|
|
|
|
* `x ~ y`: Revisions that are in `x` but not in `y`.
|
|
|
|
|
* `x | y`: Revisions that are in either `x` or `y` (or both).
|
|
|
|
|
|
|
|
|
|
(listed in order of binding strengths)
|
2021-12-14 05:46:42 +00:00
|
|
|
|
|
|
|
|
|
You can use parentheses to control evaluation order, such as `(x & y) | z` or
|
|
|
|
|
`x & (y | z)`.
|
|
|
|
|
|
2024-10-02 17:03:41 +00:00
|
|
|
|
<!-- The following format will be understood by the web site generator, and will
|
|
|
|
|
generate a folded section that can be unfolded at will. -->
|
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
??? examples
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
Given this history:
|
|
|
|
|
```
|
|
|
|
|
D
|
|
|
|
|
|\
|
|
|
|
|
| o C
|
|
|
|
|
| |
|
|
|
|
|
o | B
|
|
|
|
|
|/
|
|
|
|
|
o A
|
|
|
|
|
|
|
|
|
|
|
o root()
|
|
|
|
|
```
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x-`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D-` ⇒ `{C,B}`
|
|
|
|
|
* `B-` ⇒ `{A}`
|
|
|
|
|
* `A-` ⇒ `{root()}`
|
|
|
|
|
* `root()-` ⇒ `{}` (empty set)
|
|
|
|
|
* `none()-` ⇒ `{}` (empty set)
|
|
|
|
|
* `(D|A)-` ⇒ `{C,B,root()}`
|
|
|
|
|
* `(C|B)-` ⇒ `{A}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x+`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D+` ⇒ `{}` (empty set)
|
|
|
|
|
* `B+` ⇒ `{D}`
|
|
|
|
|
* `A+` ⇒ `{B,C}`
|
|
|
|
|
* `root()+` ⇒ `{A}`
|
|
|
|
|
* `none()+` ⇒ `{}` (empty set)
|
|
|
|
|
* `(C|B)+` ⇒ `{D}`
|
|
|
|
|
* `(B|root())+` ⇒ `{D,A}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x::`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D::` ⇒ `{D}`
|
|
|
|
|
* `B::` ⇒ `{D,B}`
|
|
|
|
|
* `A::` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `root()::` ⇒ `{D,C,B,A,root()}`
|
|
|
|
|
* `none()::` ⇒ `{}` (empty set)
|
|
|
|
|
* `(C|B)::` ⇒ `{D,C,B}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x..`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D..` ⇒ `{}` (empty set)
|
|
|
|
|
* `B..` ⇒ `{D,C}` (note that, unlike `B::`, this includes `C`)
|
|
|
|
|
* `A..` ⇒ `{D,C,B}`
|
|
|
|
|
* `root()..` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `none()..` ⇒ `{D,C,B,A,root()}`
|
|
|
|
|
* `(C|B)..` ⇒ `{D}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `::x`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `::D` ⇒ `{D,C,B,A,root()}`
|
|
|
|
|
* `::B` ⇒ `{B,A,root()}`
|
|
|
|
|
* `::A` ⇒ `{A,root()}`
|
|
|
|
|
* `::root()` ⇒ `{root()}`
|
|
|
|
|
* `::none()` ⇒ `{}` (empty set)
|
|
|
|
|
* `::(C|B)` ⇒ `{C,B,A,root()}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `..x`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `..D` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `..B` ⇒ `{B,A}`
|
|
|
|
|
* `..A` ⇒ `{A}`
|
|
|
|
|
* `..root()` ⇒ `{}` (empty set)
|
|
|
|
|
* `..none()` ⇒ `{}` (empty set)
|
|
|
|
|
* `..(C|B)` ⇒ `{C,B,A}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x::y`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D::D` ⇒ `{D}`
|
|
|
|
|
* `B::D` ⇒ `{D,B}` (note that, unlike `B..D`, this includes `B` and excludes `C`)
|
|
|
|
|
* `A::D` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `root()::D` ⇒ `{D,C,B,A,root()}`
|
|
|
|
|
* `none()::D` ⇒ `{}` (empty set)
|
|
|
|
|
* `D::B` ⇒ `{}` (empty set)
|
|
|
|
|
* `(C|B)::(C|B)` ⇒ `{C,B}`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-18 00:10:23 +00:00
|
|
|
|
**Operator** `x..y`
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `D..D` ⇒ `{}` (empty set)
|
|
|
|
|
* `B..D` ⇒ `{D,C}` (note that, unlike `B::D`, this includes `C` and excludes `B`)
|
|
|
|
|
* `A..D` ⇒ `{D,C,B}`
|
|
|
|
|
* `root()..D` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `none()..D` ⇒ `{D,C,B,A,root()}`
|
|
|
|
|
* `D..B` ⇒ `{}` (empty set)
|
|
|
|
|
* `(C|B)..(C|B)` ⇒ `{}` (empty set)
|
2024-06-16 22:34:54 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
## Functions
|
|
|
|
|
|
|
|
|
|
You can also specify revisions by using functions. Some functions take other
|
|
|
|
|
revsets (expressions) as arguments.
|
|
|
|
|
|
|
|
|
|
* `parents(x)`: Same as `x-`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
* `children(x)`: Same as `x+`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
|
|
|
|
* `ancestors(x[, depth])`: `ancestors(x)` is the same as `::x`.
|
|
|
|
|
`ancestors(x, depth)` returns the ancestors of `x` limited to the given
|
2023-09-02 06:02:35 +00:00
|
|
|
|
`depth`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2024-06-13 16:38:02 +00:00
|
|
|
|
* `descendants(x[, depth])`: `descendants(x)` is the same as `x::`.
|
|
|
|
|
`descendants(x, depth)` returns the descendants of `x` limited to the given
|
|
|
|
|
`depth`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2024-05-14 21:01:28 +00:00
|
|
|
|
* `reachable(srcs, domain)`: All commits reachable from `srcs` within
|
|
|
|
|
`domain`, traversing all parent and child edges.
|
|
|
|
|
|
2023-09-05 21:58:13 +00:00
|
|
|
|
* `connected(x)`: Same as `x::x`. Useful when `x` includes several commits.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
* `all()`: All visible commits in the repo.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
* `none()`: No commits. This function is rarely useful; it is provided for
|
|
|
|
|
completeness.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `bookmarks([pattern])`: All local bookmark targets. If `pattern` is specified,
|
|
|
|
|
this selects the bookmarks whose name match the given [string
|
|
|
|
|
pattern](#string-patterns). For example, `bookmarks(push)` would match the
|
|
|
|
|
bookmarks `push-123` and `repushed` but not the bookmark `main`. If a bookmark is
|
2023-10-31 19:30:19 +00:00
|
|
|
|
in a conflicted state, all its possible targets are included.
|
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `remote_bookmarks([bookmark_pattern[, [remote=]remote_pattern]])`: All remote
|
|
|
|
|
bookmarks targets across all remotes. If just the `bookmark_pattern` is
|
|
|
|
|
specified, the bookmarks whose names match the given [string
|
2023-11-02 05:26:07 +00:00
|
|
|
|
pattern](#string-patterns) across all remotes are selected. If both
|
2024-09-11 16:11:50 +00:00
|
|
|
|
`bookmark_pattern` and `remote_pattern` are specified, the selection is
|
2023-11-02 05:26:07 +00:00
|
|
|
|
further restricted to just the remotes whose names match `remote_pattern`.
|
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
For example, `remote_bookmarks(push, ri)` would match the bookmarks
|
2023-11-02 05:26:07 +00:00
|
|
|
|
`push-123@origin` and `repushed@private` but not `push-123@upstream` or
|
2024-09-11 16:11:50 +00:00
|
|
|
|
`main@origin` or `main@upstream`. If a bookmark is in a conflicted state, all
|
2023-11-02 05:26:07 +00:00
|
|
|
|
its possible targets are included.
|
2023-10-31 19:30:19 +00:00
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
While Git-tracking bookmarks can be selected by `<name>@git`, these bookmarks
|
|
|
|
|
aren't included in `remote_bookmarks()`.
|
2023-11-07 08:47:13 +00:00
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `tracked_remote_bookmarks([bookmark_pattern[, [remote=]remote_pattern]])`: All
|
|
|
|
|
targets of tracked remote bookmarks. Supports the same optional arguments as
|
|
|
|
|
`remote_bookmarks()`.
|
2024-07-07 23:38:29 +00:00
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `untracked_remote_bookmarks([bookmark_pattern[, [remote=]remote_pattern]])`:
|
|
|
|
|
All targets of untracked remote bookmarks. Supports the same optional arguments
|
|
|
|
|
as `remote_bookmarks()`.
|
2024-07-07 23:38:29 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
* `tags()`: All tag targets. If a tag is in a conflicted state, all its
|
|
|
|
|
possible targets are included.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
* `git_refs()`: All Git ref targets as of the last import. If a Git ref
|
|
|
|
|
is in a conflicted state, all its possible targets are included.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-07-11 04:44:17 +00:00
|
|
|
|
* `git_head()`: The Git `HEAD` target as of the last import. Equivalent to
|
|
|
|
|
`present(HEAD@git)`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-03-28 06:13:31 +00:00
|
|
|
|
* `visible_heads()`: All visible heads (same as `heads(all())`).
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-09-03 03:47:23 +00:00
|
|
|
|
* `root()`: The virtual commit that is the oldest ancestor of all other commits.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-03-28 06:13:31 +00:00
|
|
|
|
* `heads(x)`: Commits in `x` that are not ancestors of other commits in `x`.
|
2023-06-14 10:55:36 +00:00
|
|
|
|
Note that this is different from
|
|
|
|
|
[Mercurial's](https://repo.mercurial-scm.org/hg/help/revsets) `heads(x)`
|
|
|
|
|
function, which is equivalent to `x ~ x-`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2022-04-13 20:55:47 +00:00
|
|
|
|
* `roots(x)`: Commits in `x` that are not descendants of other commits in `x`.
|
2023-06-14 10:55:36 +00:00
|
|
|
|
Note that this is different from
|
|
|
|
|
[Mercurial's](https://repo.mercurial-scm.org/hg/help/revsets) `roots(x)`
|
|
|
|
|
function, which is equivalent to `x ~ x+`.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-03-25 03:14:26 +00:00
|
|
|
|
* `latest(x[, count])`: Latest `count` commits in `x`, based on committer
|
|
|
|
|
timestamp. The default `count` is 1.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2022-10-25 13:20:59 +00:00
|
|
|
|
* `merges()`: Merge commits.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-10-31 19:30:19 +00:00
|
|
|
|
* `description(pattern)`: Commits that have a description matching the given
|
|
|
|
|
[string pattern](#string-patterns).
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-10-31 19:30:19 +00:00
|
|
|
|
* `author(pattern)`: Commits with the author's name or email matching the given
|
|
|
|
|
[string pattern](#string-patterns).
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-08-14 00:35:11 +00:00
|
|
|
|
* `mine()`: Commits where the author's email matches the email of the current
|
|
|
|
|
user.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2023-10-31 19:30:19 +00:00
|
|
|
|
* `committer(pattern)`: Commits with the committer's name or email matching the
|
|
|
|
|
given [string pattern](#string-patterns).
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2024-06-08 00:42:15 +00:00
|
|
|
|
* `author_date(pattern)`: Commits with author dates matching the specified [date
|
|
|
|
|
pattern](#date-patterns).
|
|
|
|
|
|
|
|
|
|
* `committer_date(pattern)`: Commits with committer dates matching the specified
|
|
|
|
|
[date pattern](#date-patterns).
|
|
|
|
|
|
2022-11-15 08:12:37 +00:00
|
|
|
|
* `empty()`: Commits modifying no files. This also includes `merges()` without
|
2023-09-03 03:47:23 +00:00
|
|
|
|
user modifications and `root()`.
|
2023-10-31 19:30:19 +00:00
|
|
|
|
|
2024-08-24 17:53:00 +00:00
|
|
|
|
* `files(expression)`: Commits modifying paths matching the given [fileset
|
2024-07-06 10:50:04 +00:00
|
|
|
|
expression](filesets.md).
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
|
|
|
|
Paths are relative to the directory `jj` was invoked from. A directory name
|
|
|
|
|
will match all files in that directory and its subdirectories.
|
|
|
|
|
|
|
|
|
|
For example, `file(foo)` will match files `foo`, `foo/bar`, `foo/bar/baz`.
|
|
|
|
|
It will *not* match `foobar` or `bar/foo`.
|
2023-10-31 19:30:19 +00:00
|
|
|
|
|
2024-07-06 10:50:04 +00:00
|
|
|
|
Some file patterns might need quoting because the `expression` must also be
|
|
|
|
|
parsable as a revset. For example, `.` has to be quoted in `file(".")`.
|
|
|
|
|
|
2024-07-08 11:20:41 +00:00
|
|
|
|
* `diff_contains(text[, files])`: Commits containing diffs matching the given
|
|
|
|
|
`text` pattern line by line.
|
|
|
|
|
|
|
|
|
|
The search paths can be narrowed by the `files` expression. All modified files
|
|
|
|
|
are scanned by default, but it is likely to change in future version to
|
|
|
|
|
respect the command line path arguments.
|
|
|
|
|
|
|
|
|
|
For example, `diff_contains("TODO", "src")` will search revisions where "TODO"
|
|
|
|
|
is added to or removed from files under "src".
|
|
|
|
|
|
2024-08-24 17:53:00 +00:00
|
|
|
|
* `conflicts()`: Commits with conflicts.
|
2023-11-02 05:26:07 +00:00
|
|
|
|
|
2022-11-07 07:29:35 +00:00
|
|
|
|
* `present(x)`: Same as `x`, but evaluated to `none()` if any of the commits
|
2024-09-11 16:11:50 +00:00
|
|
|
|
in `x` doesn't exist (e.g. is an unknown bookmark name.)
|
2021-12-14 05:46:42 +00:00
|
|
|
|
|
2024-04-01 01:40:19 +00:00
|
|
|
|
* `working_copies()`: The working copy commits across all the workspaces.
|
|
|
|
|
|
2024-06-19 02:11:41 +00:00
|
|
|
|
??? examples
|
|
|
|
|
|
|
|
|
|
Given this history:
|
|
|
|
|
```
|
|
|
|
|
E
|
|
|
|
|
|
|
|
|
|
|
| D
|
|
|
|
|
|/|
|
|
|
|
|
| o C
|
|
|
|
|
| |
|
|
|
|
|
o | B
|
|
|
|
|
|/
|
|
|
|
|
o A
|
|
|
|
|
|
|
|
|
|
|
o root()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**function** `reachable()`
|
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `reachable(E, A..)` ⇒ `{E,D,C,B}`
|
|
|
|
|
* `reachable(D, A..)` ⇒ `{E,D,C,B}`
|
|
|
|
|
* `reachable(C, A..)` ⇒ `{E,D,C,B}`
|
|
|
|
|
* `reachable(B, A..)` ⇒ `{E,D,C,B}`
|
|
|
|
|
* `reachable(A, A..)` ⇒ `{}` (empty set)
|
2024-06-19 02:11:41 +00:00
|
|
|
|
|
|
|
|
|
**function** `connected()`
|
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `connected(E|A)` ⇒ `{E,B,A}`
|
|
|
|
|
* `connected(D|A)` ⇒ `{D,C,B,A}`
|
|
|
|
|
* `connected(A)` ⇒ `{A}`
|
2024-06-19 02:11:41 +00:00
|
|
|
|
|
|
|
|
|
**function** `heads()`
|
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `heads(E|D)` ⇒ `{E,D}`
|
|
|
|
|
* `heads(E|C)` ⇒ `{E,C}`
|
|
|
|
|
* `heads(E|B)` ⇒ `{E}`
|
|
|
|
|
* `heads(E|A)` ⇒ `{E}`
|
|
|
|
|
* `heads(A)` ⇒ `{A}`
|
2024-06-19 02:11:41 +00:00
|
|
|
|
|
|
|
|
|
**function** `roots()`
|
|
|
|
|
|
2024-06-19 10:48:01 +00:00
|
|
|
|
* `roots(E|D)` ⇒ `{E,D}`
|
|
|
|
|
* `roots(E|C)` ⇒ `{E,C}`
|
|
|
|
|
* `roots(E|B)` ⇒ `{B}`
|
|
|
|
|
* `roots(E|A)` ⇒ `{A}`
|
|
|
|
|
* `roots(A)` ⇒ `{A}`
|
2024-06-19 02:11:41 +00:00
|
|
|
|
|
2023-08-16 09:41:21 +00:00
|
|
|
|
## String patterns
|
|
|
|
|
|
2023-10-31 19:30:19 +00:00
|
|
|
|
Functions that perform string matching support the following pattern syntax:
|
2023-08-16 09:41:21 +00:00
|
|
|
|
|
2023-10-31 19:30:19 +00:00
|
|
|
|
* `"string"`, or `string` (the quotes are optional), or `substring:"string"`:
|
|
|
|
|
Matches strings that contain `string`.
|
2023-08-19 00:59:40 +00:00
|
|
|
|
* `exact:"string"`: Matches strings exactly equal to `string`.
|
2023-10-31 19:30:19 +00:00
|
|
|
|
* `glob:"pattern"`: Matches strings with Unix-style shell [wildcard
|
|
|
|
|
`pattern`](https://docs.rs/glob/latest/glob/struct.Pattern.html).
|
2024-07-21 12:44:43 +00:00
|
|
|
|
* `regex:"pattern"`: Matches substrings with [regular
|
|
|
|
|
expression `pattern`](https://docs.rs/regex/latest/regex/#syntax).
|
2023-08-16 09:41:21 +00:00
|
|
|
|
|
2024-06-28 09:35:50 +00:00
|
|
|
|
You can append `-i` after the kind to match case‐insensitively (e.g.
|
|
|
|
|
`glob-i:"fix*jpeg*"`).
|
|
|
|
|
|
2024-06-08 00:42:15 +00:00
|
|
|
|
## Date patterns
|
|
|
|
|
|
|
|
|
|
Functions that perform date matching support the following pattern syntax:
|
|
|
|
|
|
|
|
|
|
* `after:"string"`: Matches dates exactly at or after the given date.
|
|
|
|
|
* `before:"string"`: Matches dates before, but not including, the given date.
|
|
|
|
|
|
|
|
|
|
Date strings can be specified in several forms, including:
|
|
|
|
|
|
|
|
|
|
* 2024-02-01
|
|
|
|
|
* 2024-02-01T12:00:00
|
|
|
|
|
* 2024-02-01T12:00:00-08:00
|
|
|
|
|
* 2024-02-01 12:00:00
|
|
|
|
|
* 2 days ago
|
|
|
|
|
* 5 minutes ago
|
|
|
|
|
* yesterday
|
|
|
|
|
* yesterday 5pm
|
|
|
|
|
* yesterday 10:30
|
|
|
|
|
* yesterday 15:30
|
|
|
|
|
|
2022-11-25 10:27:13 +00:00
|
|
|
|
## Aliases
|
|
|
|
|
|
2022-11-26 11:41:55 +00:00
|
|
|
|
New symbols and functions can be defined in the config file, by using any
|
|
|
|
|
combination of the predefined symbols/functions and other aliases.
|
2022-11-25 10:27:13 +00:00
|
|
|
|
|
2024-06-05 13:29:10 +00:00
|
|
|
|
Alias functions can be overloaded by the number of parameters. However, builtin
|
|
|
|
|
function will be shadowed by name, and can't co-exist with aliases.
|
|
|
|
|
|
2022-11-25 10:27:13 +00:00
|
|
|
|
For example:
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2022-11-25 10:27:13 +00:00
|
|
|
|
```toml
|
|
|
|
|
[revset-aliases]
|
2024-03-03 09:26:20 +00:00
|
|
|
|
'HEAD' = '@-'
|
2024-08-25 12:47:44 +00:00
|
|
|
|
'user()' = 'user("me@example.org")'
|
2022-11-26 11:41:55 +00:00
|
|
|
|
'user(x)' = 'author(x) | committer(x)'
|
2022-11-25 10:27:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-08-15 21:49:11 +00:00
|
|
|
|
### Built-in Aliases
|
|
|
|
|
|
|
|
|
|
The following aliases are built-in and used for certain operations. These functions
|
2024-09-13 05:25:47 +00:00
|
|
|
|
are defined as aliases in order to allow you to overwrite them as needed.
|
2023-08-15 21:49:11 +00:00
|
|
|
|
See [revsets.toml](https://github.com/martinvonz/jj/blob/main/cli/src/config/revsets.toml)
|
|
|
|
|
for a comprehensive list.
|
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `trunk()`: Resolves to the head commit for the trunk bookmark of the remote
|
|
|
|
|
named `origin` or `upstream`. The bookmarks `main`, `master`, and `trunk` are
|
2023-09-20 02:20:30 +00:00
|
|
|
|
tried. If more than one potential trunk commit exists, the newest one is
|
2024-09-11 16:11:50 +00:00
|
|
|
|
chosen. If none of the bookmarks exist, the revset evaluates to `root()`.
|
2023-08-15 21:49:11 +00:00
|
|
|
|
|
2024-05-31 10:56:05 +00:00
|
|
|
|
When working with an existing Git repository (via `jj git clone` or
|
|
|
|
|
`jj git init`), `trunk()` will be overridden at the repository level
|
2024-09-11 16:11:50 +00:00
|
|
|
|
to the default bookmark of the remote `origin`.
|
2024-03-04 10:52:48 +00:00
|
|
|
|
|
2023-08-15 21:49:11 +00:00
|
|
|
|
You can [override](./config.md) this as appropriate. If you do, make sure it
|
|
|
|
|
always resolves to exactly one commit. For example:
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[revset-aliases]
|
2024-09-11 16:11:50 +00:00
|
|
|
|
'trunk()' = 'your-bookmark@your-remote'
|
2023-08-15 21:49:11 +00:00
|
|
|
|
```
|
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `builtin_immutable_heads()`: Resolves to `trunk() | tags() | untracked_remote_bookmarks()`.
|
2024-08-01 19:17:16 +00:00
|
|
|
|
It is used as the default definition for `immutable_heads()` below. it is not
|
2024-09-11 16:11:50 +00:00
|
|
|
|
recommended to redefined this alias. Prefer to redefine `immutable_heads()`
|
|
|
|
|
instead.
|
2024-08-01 19:17:16 +00:00
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
* `immutable_heads()`: Resolves to `trunk() | tags() | untracked_remote_bookmarks()`
|
|
|
|
|
by default. It is actually defined as `builtin_immutable_heads()`, and can be
|
|
|
|
|
overridden as required. See [here](config.md#set-of-immutable-commits) for
|
|
|
|
|
details.
|
2023-10-23 05:36:36 +00:00
|
|
|
|
|
2024-05-16 23:34:43 +00:00
|
|
|
|
* `immutable()`: The set of commits that `jj` treats as immutable. This is
|
2024-08-01 19:17:16 +00:00
|
|
|
|
equivalent to `::(immutable_heads() | root())`. It is not recommended to redefine
|
|
|
|
|
this alias. Note that modifying this will *not* change whether a commit is immutable.
|
2024-09-13 05:25:47 +00:00
|
|
|
|
To do that, edit `immutable_heads()`.
|
2024-05-16 23:34:43 +00:00
|
|
|
|
|
|
|
|
|
* `mutable()`: The set of commits that `jj` treats as mutable. This is
|
2024-08-01 19:17:16 +00:00
|
|
|
|
equivalent to `~immutable()`. It is not recommended to redefined this alias.
|
|
|
|
|
Note that modifying this will *not* change whether a commit is immutable.
|
|
|
|
|
To do that, edit `immutable_heads()`.
|
2024-05-16 23:34:43 +00:00
|
|
|
|
|
2024-04-11 19:01:26 +00:00
|
|
|
|
|
|
|
|
|
## The `all:` modifier
|
|
|
|
|
|
|
|
|
|
Certain commands (such as `jj rebase`) can take multiple revset arguments, and
|
|
|
|
|
each of these may resolve to one-or-many revisions. By default, `jj` will not
|
|
|
|
|
allow revsets that resolve to more than one revision — a so-called "large
|
|
|
|
|
revset" — and will ask you to confirm that you want to proceed by
|
|
|
|
|
prefixing it with the `all:` modifier.
|
|
|
|
|
|
|
|
|
|
If you set the `ui.always-allow-large-revsets` option to `true`, `jj` will
|
|
|
|
|
behave as though the `all:` modifier was used every time it would matter.
|
|
|
|
|
|
|
|
|
|
An `all:` modifier before a revset expression does not otherwise change its
|
|
|
|
|
meaning. Strictly speaking, it is not part of the revset language. The notation
|
|
|
|
|
is similar to the modifiers like `glob:` allowed before [string
|
|
|
|
|
patterms](#string-patterns).
|
|
|
|
|
|
|
|
|
|
For example, `jj rebase -r w -d xyz+` will rebase `w` on top of the child of
|
|
|
|
|
`xyz` as long as `xyz` has exactly one child.
|
|
|
|
|
|
|
|
|
|
If `xyz` has more than one child, the `all:` modifier is *not* specified, and
|
|
|
|
|
`ui.always-allow-large-revsets` is `false` (the default), `jj rebase -r w -d
|
|
|
|
|
xyz+` will return an error.
|
|
|
|
|
|
|
|
|
|
If `ui.always-allow-large-revsets` was `true`, the above command would act as if
|
|
|
|
|
`all:` was set (see the next paragraph).
|
|
|
|
|
|
|
|
|
|
With the `all:` modifier, `jj rebase -r w -d all:xyz+` will make `w` into a merge
|
|
|
|
|
commit if `xyz` has more than one child. The `all:` modifier confirms that the
|
|
|
|
|
user expected `xyz` to have more than one child.
|
|
|
|
|
|
|
|
|
|
A more useful example: if `w` is a merge commit, `jj rebase -s w -d all:w- -d
|
|
|
|
|
xyz` will add `xyz` to the list of `w`'s parents.
|
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
## Examples
|
|
|
|
|
|
2022-08-25 23:34:18 +00:00
|
|
|
|
Show the parent(s) of the working-copy commit (like `git log -1 HEAD`):
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
|
|
|
|
jj log -r @-
|
|
|
|
|
```
|
|
|
|
|
|
2024-01-31 20:32:10 +00:00
|
|
|
|
Show all ancestors of the working copy (like plain `git log`)
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2024-01-31 20:32:10 +00:00
|
|
|
|
jj log -r ::@
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
|
|
|
|
|
2024-09-11 16:11:50 +00:00
|
|
|
|
Show commits not on any remote bookmark:
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
|
|
|
|
```
|
2024-09-11 16:11:50 +00:00
|
|
|
|
jj log -r 'remote_bookmarks()..'
|
2023-01-12 10:01:35 +00:00
|
|
|
|
```
|
|
|
|
|
|
2024-01-31 20:32:10 +00:00
|
|
|
|
Show commits not on `origin` (if you have other remotes like `fork`):
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2024-09-11 16:11:50 +00:00
|
|
|
|
jj log -r 'remote_bookmarks(remote=origin)..'
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Show the initial commits in the repo (the ones Git calls "root commits"):
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2024-06-04 10:33:35 +00:00
|
|
|
|
jj log -r 'root()+'
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Show some important commits (like `git --simplify-by-decoration`):
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2024-09-11 16:11:50 +00:00
|
|
|
|
jj log -r 'tags() | bookmarks()'
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Show local commits leading up to the working copy, as well as descendants of
|
|
|
|
|
those commits:
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
revsets: allow `::` as synonym for `:`
The `--allow-large-revsets` flag we have on `jj rebase` and `jj new`
allows the user to do e.g. `jj rebase --allow-large-revsets -b
main.. -d main` to rebase all commits that are not in main onto
main. The reason we don't allow these revsets to resolve to multiple
commits by default is that we think users might specify multiple
commits by mistake. That's probably not much of a problem with `jj
rebase -b` (maybe we should always allow that to resolve to multiple
commits), but the user might want to know if `jj rebase -d @-`
resolves to multiple commits.
One problem with having a flag to allow multiple commits is that it
needs to be added to every command where we want to allow multiple
commits but default to one. Also, it should probably apply to each
revset argument those commands take. For example, even if the user
meant `-b main..` to resolve to multiple commits, they might not have
meant `-d main` to resolve to multiple commits (which it will in case
of a conflicted branch), so we might want separate
`--allow-large-revsets-in-destination` and
`--allow-large-revsets-in-source`, which gets quite cumbersome. It
seems better to have some syntax in the individual revsets for saying
that multiple commits are allowed.
One proposal I had was to use a `multiple()` revset function which
would have no effect in general but would be used as a marker if used
at the top level (e.g. `jj rebase -d 'multiple(@-)'`). After some
discussion on the PR adding that function (#1911), it seems that the
consensus is to instead use a prefix like `many:` or `all:`. That
avoids the problem with having a function that has no effect unless
it's used at the top level (`jj rebase -d 'multiple(x)|y'` would have
no effect).
Since we already have the `:` operator for DAG ranges, we need to
change it to make room for `many:`/`all:` syntax. This commit starts
that by allowing both `:` and `::`.
I have tried to update the documentation in this commit to either
mention both forms, or just the new and preferred `::` form. However,
it's useless to search for `:` in Rust code, so I'm sure I've missed
many instances. We'll have to address those as we notice them. I'll
let most tests use `:` until we deprecate it or delete it.
2023-07-27 23:27:44 +00:00
|
|
|
|
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2024-09-11 16:11:50 +00:00
|
|
|
|
jj log -r '(remote_bookmarks()..@)::'
|
2021-12-14 05:46:42 +00:00
|
|
|
|
```
|
2021-12-16 06:16:22 +00:00
|
|
|
|
|
|
|
|
|
Show commits authored by "martinvonz" and containing the word "reset" in the
|
|
|
|
|
description:
|
2023-01-12 10:01:35 +00:00
|
|
|
|
|
2021-12-16 06:16:22 +00:00
|
|
|
|
```
|
|
|
|
|
jj log -r 'author(martinvonz) & description(reset)'
|
|
|
|
|
```
|