Commit graph

65 commits

Author SHA1 Message Date
Yuya Nishihara
186f639dfb docs: sort list of operators in order of binding strengths
We can add a separate precedence/associativity table, but I think the ordered
list is good enough. Nullary :: and .. have no binding, but inserted after the
infix versions for brevity.
2024-06-07 11:27:37 +09:00
Matthew Davidson
88cb56d3dd docs: Fix zsh-breaking logging example 2024-06-04 20:44:11 +09:00
Matt Stark
fa6f5e3880 Add the revsets mutable and immutable.
I add them as aliases, since a user may instead choose to define `immutable_heads()`, for example, as `heads(immutable())`, and the define `immutable()` instead.
2024-05-22 09:19:46 +10:00
dploch
a49da4ad01 revset: implement a 'reachable(src, domain)' expression
This revset correctly implements "reachability" from a set of source commits following both parent and child edges as far as they can go within a domain set. This type of 'bfs' query is currently impossible to express with existing revset functions.
2024-05-21 10:52:31 -04:00
Yuya Nishihara
5b769c5c9e fileset, revset, templater: add support for single-quoted raw string literals
Since fileset/revset/template expressions are specified as command-line
arguments, it's sometimes convenient to use single quotes instead of double
quotes. Various scripting languages parse single-quoted strings in various ways,
but I choose the TOML rule because it's simple and practically useful. TOML is
our config language, so copying the TOML syntax would be less surprising than
borrowing it from another language.

https://github.com/toml-lang/toml/issues/188
2024-04-25 11:14:33 +09:00
Ilya Grigoriev
77eaf67f96 revsets.md: document the all: prefix modifier for revsets
While this is arguably not part of the revset language, this
is a likely place for a user to look.

See https://discord.com/channels/968932220549103686/968932220549103689/1228065431281995837
2024-04-20 14:12:26 -07:00
Yuya Nishihara
8b32a8a916 revset: add support for file(kind:pattern) syntax
There are no more callers of parse_function_argument_to_string(), so it's
removed. This function was a thin wrapper of literal parser, and can be
easily reintroduced if needed.
2024-04-07 19:43:29 +09:00
Christoph Koehler
7bde6ddc29 revset: add working_copies() function
It includes the working copy commit of every workspace of the repo.

Implements #3384
2024-04-01 19:36:53 -06:00
Yuya Nishihara
78edb615a2 docs: update revset alias example to something very different from builtins
We've added mine() function, so this alias looks confusing.
2024-03-03 21:35:41 +09:00
Yuya Nishihara
815437598f revset: disable parsing rules of legacy dag range operator
The legacy parsing rules are turned into compatibility errors. The x:y rule
is temporarily enabled when parsing string patterns. It's weird, but we can't
isolate the parsing function because a string pattern may be defined in an
alias.
2024-02-14 10:04:56 +09:00
Ilya Grigoriev
fa123bbfee docs: emphasize and clarify log revsets relevant to people coming from git
I couldn't come up with a Git analogue of `jj log`, but I think it's OK
leaving it as a TODO makes the point. Perhaps somebody can figure it
out.

Also, all the correspondences are not completely precise, so I didn't
emphasize it every single time.
2024-01-31 15:51:40 -08:00
Yuya Nishihara
2ac9865ce7 revset: exclude @git branches from remote_branches()
As discussed in Discord, it's less useful if remote_branches() included
Git-tracking branches. Users wouldn't consider the backing Git repo as
a remote.

We could allow explicit 'remote_branches(remote=exact:"git")' query by changing
the default remote pattern to something like 'remote=~exact:"git"'. I don't
know which will be better overall, but we don't have support for negative
patterns anyway.
2023-11-08 07:34:30 +09:00
Ilya Grigoriev
adc8433204 mkdocs: make MkDocs work with more GitHub-like list formatting
This adds two MkDocs extensions to make list handling more flexible.
It took some trial-and-error, but it seems this config works OK.

revsets.md: use saner formatting that is now possible.

sapling-comparison.md: this was the one case I saw made worse by the
new plugins. I changed the Markdown formatting, it still looks sane.
2023-11-03 19:15:37 -07:00
Ilya Grigoriev
4c490d2ca9 revsets.md: correct description of "visible commits" 2023-10-31 23:41:41 -07:00
Ilya Grigoriev
a3f21f7a9d revsets.md: clarify string patterns and file patterns
I had to increase indent on two list items for multiple paragraphs to work in
MkDocs.
2023-10-31 17:49:49 -07:00
Martin von Zweigbergk
171896aefa docs: mention the immutable_heads() in our list of built-in aliases 2023-10-23 12:05:09 -07:00
Yuya Nishihara
cfcc76571c revset: add support for glob:pattern 2023-10-21 09:55:01 +09:00
Ilya Grigoriev
6d5390d1db cli: add upstream remote to default trunk()
This makes trunk() correct after `jj git fetch --remote upstream --branch
main`.
2023-09-19 20:51:23 -07:00
Ilya Grigoriev
0c31e0ba61 trunk() docs fix: commits aren't tried in order; newest commit wins
That's my understanding of how `latest()` revset works.
2023-09-19 20:51:23 -07:00
Yuya Nishihara
96cb3a6053 docs: use branch@remote syntax in trunk() example
It's simpler, and user-specified trunk() wouldn't need fallback.
2023-09-19 21:29:08 +09:00
Ruben Slabbert
f2f5ded5f0 revsets: add trunk alias with default to main/master/root 2023-09-17 10:17:23 +10:00
James Sully
0946934ca6 revset: Add optional argument n to ancestors() in revset language 2023-09-08 02:50:58 +10:00
Martin von Zweigbergk
d047512115 docs: prefer new revset operator :: over deprecated :
Now that we're very close to a release, it should be fine to use the
new syntax in our documentation. This effecttively backs out
37436f7344.
2023-09-06 13:09:14 -07:00
Martin von Zweigbergk
c7d1932546 release: release version 0.9.0
Thanks to everyone who's contributed!
2023-09-06 10:57:57 -07:00
Yuya Nishihara
b0c8e9ef62 revset: add 0-ary "::" and ".." operators as short for "all()" and "~root()"
Suppose "x::y" is the operator that defaults to "root()::visible_heads()"
respectively, "::" is identical to "all()". Since we've just changed the
behavior of "..y", ".." is now "root()..visible_heads()" meaning "~root()".
2023-09-05 10:40:04 +09:00
Yuya Nishihara
6b2ad23f8f revset: evaluate "..y" expression to "root()..y"
This seems useful since the root commit is often uninteresting. It's also
consistent with "x::y" in a way that the left operand defaults to "root()".
2023-09-05 10:40:04 +09:00
Yuya Nishihara
e3c85d6ecc revset: convert root symbol to function
The idea is that we can fully eliminate special symbols that would otherwise
shadow user branches, tags, or change ID prefixes.

Closes #2095
2023-09-04 10:36:30 +09:00
Yuya Nishihara
c08fab60da docs: update description of @ revset expression, mention name@remote syntax
Since I'm going to remove the root symbol, it doesn't make sense to leave
@ in the priority list.
2023-09-04 10:36:30 +09:00
Yuya Nishihara
b6794ca04a revset: rename literal:"" prefix to exact:""
Per discussion in #2107, I believe "exact" is preferred.

We can also change the default to exact match, but it doesn't always make
sense. Exact match would be useful for branches(), but not for description().
We could define default per predicate function, but I'm pretty sure I cannot
remember which one is which.
2023-08-19 11:33:57 +09:00
Yuya Nishihara
ebdc22a65e revset: add support for explicit substring:"..." prefix
git-branchless calls it a substring, so let's do the same.

FWIW, I copied literal:_ from Mercurial, but it's exact:_ in git-branchless.
I have no idea which one is preferred. Since this feature isn't released, we
can freely change it if exact:_ makes more sense.

https://github.com/arxanas/git-branchless/wiki/Reference:-Revsets#patterns
2023-08-19 10:32:59 +09:00
Yuya Nishihara
81f1ae38b3 revset: add literal:"string" pattern syntax
The syntax is slightly different from Mercurial. In Mercurial, a pattern must
be quoted like "<kind>:<needle>". In JJ, <kind> is a separate parsing node, and
it must not appear in a quoted string. This allows us to report unknown prefix
as an error.

There's another subtle behavior difference. In Mercurial, branch(unknown) is
an error, whereas our branches(literal:unknown) is resolved to an empty set.
I think erroring out doesn't make sense for JJ since branches() by default
performs substring matching, so its behavior is more like a filter.

The parser abuses DAG range syntax for now. It can be rewritten once we remove
the deprecated x:y range syntax.
2023-08-17 07:42:12 +09:00
Yuya Nishihara
5b3c73dfc4 revset: insert StringPattern enum to add support for other kind of matching 2023-08-17 07:42:12 +09:00
Emily Fox
9ba9ecd708 revset: add function mine() 2023-08-16 11:00:14 -05:00
Martin von Zweigbergk
a8de6f3695 docs: revert to using revset operator : instead of ::
Since our latest release doesn't support `::`, we shouldn't tell the
user to use it.

This commit should be backed out once we've released jj 0.9.0.
2023-08-01 21:58:43 +00:00
Martin von Zweigbergk
48580ed8b1 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-28 22:30:40 -07:00
Yuya Nishihara
f5f61f6bfe revset: resolve "HEAD@git" just like other pseudo @git branches
I don't think this would be practically useful, but consistent UX is
important.

Fixes #1843
2023-07-11 16:29:27 +09:00
Martin von Zweigbergk
b01d6cdf5d docs: note how our heads() and roots() revsets differ from hg's 2023-06-14 14:08:58 +02:00
Martin von Zweigbergk
18d73bc673 docs: don't say "both inclusive" about x:y and x..y revset endpoint
We currently say that `x..y` is "Ancestors of `y` that are not also
ancestors of `x`, both inclusive.". However, it's easy to think that
"both inclusive" means that both `x` and `y` are included in the set,
which is not the case. What we mean is more like "{Ancestors of `y`,
including `y` itself} that are not also {ancestors of `x`, including
`x` itself}.". Given that we already define ancestors and descendants
as being inclusive on the lines above, and we also give the equivalent
expressions using the `x:` and `:y` operators, it's probably best to
just skip the "both inclusive" parts.
2023-05-05 22:26:27 -07:00
Martin von Zweigbergk
1d5edddef7 docs: clarify that file() revsets match recursively 2023-04-25 14:57:57 -07:00
Martin von Zweigbergk
24a512683b revset: add a revset function for finding commits with conflicts
This adds `conflict()` revset that selects commits with conflicts. We
may want to extend it later to consider only conflicts at certain
paths.
2023-04-06 16:46:21 -07:00
Martin von Zweigbergk
e1c57338a1 revset: split out no-args head() to visible_heads()
The `heads()` revset function with one argument is the counterpart to
`roots()`. Without arguments, it returns the visible heads in the
repo, i.e. `heads(all())`. The two use cases are quite different, and
I think it would be good to clarify that the no-arg form returns the
visible heads, so let's split that out to a new `visible_heads()`
function.
2023-04-03 23:46:34 -07:00
Yuya Nishihara
0532301e03 revset: add latest(candidates, count) predicate
This serves the role of limit() in Mercurial. Since revsets in JJ is
(conceptually) an unordered set, a "limit" predicate should define its
ordering criteria. That's why the added predicate is named as "latest".

Closes #1110
2023-03-25 23:48:50 +09:00
tp-woven
39cbabf58e Clarify that files() is relative 2023-03-06 13:54:38 +09:00
Yuya Nishihara
038497638f revset: parse keyword arguments, accept remote_branches(remote=needle)
The syntax is identical to Mercurial's revset, which is derived from Python.
2023-02-09 12:11:58 +09:00
Samuel Tardieu
a7aed0171d style: fix typos found by codespell 2023-01-28 07:23:45 -08:00
Vamsi Avula
60d1537731 let branches and remote_branches revset functions take needles as arguments
- branches has the signature branches([needle]), meaning the needle is optional (branches() is equivalent to branches("")) and it matches all branches whose name contains needle as a substring
- remote_branches has the signature remote_branches([branch_needle[, remote_needle]]), meaning it can be called with no arguments, or one argument (in which case, it's similar to branches), or two arguments where the first argument matches branch names and the second argument matches remote names (similar to branches, remote_branches(), remote_branches("") and remote_branches("", "") are all equivalent)
2023-01-16 12:15:30 +05:30
Ilya Grigoriev
50321f851f revsets.md: Add a sentence to clarify connected 2023-01-14 15:52:51 -08:00
Yuya Nishihara
48d10d648c revset: add unary negate (or set complement) operator '~y'
Because a unary negation node '~y' is more primitive than the corresponding
difference node 'x~y', '~y' is easier to deal with while rewriting the tree.
That's the main reason to add RevsetExpression::NotIn node.

As we have a NotIn node, it makes sense to add an operator for that. This
patch reuses '~' token, which I feel intuitive since the other set operators
looks like bitwise ops. Another option is '!'.

The unary '~' operator has the highest precedence among the set operators,
but they are lower than the ranges. This might be counter intuitive, but
useful because a prefix range ':x' can be negated without parens.

Maybe we can remove the redundant infix operator 'x ~ y', but it isn't
decided yet.
2022-11-29 15:46:15 +09:00
Yuya Nishihara
70292f79b7 revset: implement function alias expansion
Function parameters are processed as local symbols while substituting
alias expression. This isn't as efficient as Mercurial which caches
a tree of fully-expanded function template, but that wouldn't matter in
practice.
2022-11-29 04:17:12 +09:00
Yuya Nishihara
c5ed3e1477 revset: for short hash, look up both commit and change ids to disambiguate
Because the use of the change id is recommended, any operation should abort
if a valid change id happens to match a commit id. We still try the commit
id lookup first as the change id lookup is more costly.

Ambiguous change/commit id is reported as AmbiguousCommitIdPrefix for now.
Maybe we can merge AmbiguousCommit/ChangeIdPrefix errors into one?

Closes #799
2022-11-28 17:30:53 +09:00