ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

26 commits

Author SHA1 Message Date
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
Yuya Nishihara
8b00a64ab2 cli: load revset aliases from config file
Aliases are loaded at WorkspaceCommandHelper::new() as it's easier to warn
invalid declarations there. Not all commands use revsets, but many do, so
I think it's okay to always pay the loading cost. Parsing the declaration
part (i.e. a symbol) should be fast anyway.

The nested error message isn't super readable, but seems good enough.

Config syntax to bikeshed:
- naming: [revset-alias] vs [revset-aliases] ?
- function alias will need quotes: 'f(x)' = 'x'
2022-11-27 20:12:22 +09:00
Yuya Nishihara
a81ebeb85e revset: add empty() predicate to find commits with no file change
The expression 'x ~ empty()' is identical to 'x & file(".")', but more
intuitive.

Note that 'x ~ empty()' is slower than 'x & file(".")' since the negative
intersection isn't optimized right now. I think that can be handled as
follows: 'x ~ filter(f)' -> 'x & filter(!f)' -> 'filter(!f, x)'
2022-11-16 08:50:33 +09:00
Yuya Nishihara
fa3ad16bf2 revset: add present(set) predicate that suppresses NoSuchRevision error
This is copied from Mercurial. Typical use case I have in mind is
"present(master) | present(main)" in stock revset.
2022-11-07 21:41:54 +09:00
Yuya Nishihara
62511f7cad revset: extend file() predicate to accept more than one paths
'file(a, b)' could be expressed as 'file(a) | file(b)', but the former is
easier to type and can be evaluated efficiently without optimization step.
2022-11-02 01:02:37 +09:00
Yuya Nishihara
59717aa187 revset: remove redundant candidates argument from merges()
Since 'merges()' just filters the candidates set per item, it doesn't need
a candidates argument. Perhaps, 'merges(x)' could be a predicate to select
merge commits within a subgraph 'x', but I don't know if that would be
useful.
2022-10-27 21:33:35 +09:00
Yuya Nishihara
373c63b414 revset: remove redundant candidates argument from filter predicates 2022-10-27 21:33:35 +09:00
Yuya Nishihara
cb2fcde560 revset: implement file(pattern[, candidates]) predicate
The name "file()" is just copied from hg. I'm not sure if it's good in
jj's context, but I couldn't find a better name.
2022-10-24 01:48:00 +09:00
Martin von Zweigbergk
b8f59f419c docs: hyphenate "working-copy" when used as a compound modifier 2022-08-25 18:08:36 -07:00
Martin von Zweigbergk
16cb7fdee8 docs: describe the foo@ revset syntax
We have supported multiple workspaces for six months now, but I forgot
to remove a note in the revset doc saying that we don't support
it. Also update the text to descibe how to refer to the working-copy
commit in another workspace.
2022-08-25 18:08:36 -07:00
Martin von Zweigbergk
0789a8a4c0 revsets: allow single internal - and + characters in symbols (#46) 2022-04-28 08:14:15 -07:00
Martin von Zweigbergk
7e79f25508 revset: add a roots() function 2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
9ff21d8924 revset: add a connected() function
This introduces a `connected(x)` function, which is simply the same as
`x:x`. It's occasionally useful if `x` is a long expression. It's also
useful as a building block for `root(x)` (coming soon).
2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
277f42d98a revsets: add author() and committer() functions (#46)
Filtering by the author or committer is quite common.
2021-12-15 22:50:29 -08:00
Martin von Zweigbergk
7d3d0fe83c revsets: allow the .. operator to be used as prefix or suffix (#46)
It makes sense to omit either of the arguments of the `..` operator,
even though `..x` is equivalent to `:x`. `x..`, with a implied right
argument of `heads()` is more useful.
2021-12-15 22:16:22 -08:00
Martin von Zweigbergk
4c71c763e9 docs: document revsets (#46)
Now that revset operators are not as embarrassing as before, let's
document them.
2021-12-15 16:56:45 -08:00