Skip to content

Conversation

@thoughtpolice
Copy link
Member

@thoughtpolice thoughtpolice commented Sep 25, 2025

It turns out that the use case I had for exactly() was slightly more subtle, and I need range support. In particular, usage of exactly() in expressions used by revsets.log-graph-prioritize can and will cause jj log to fail if the assertion fails; in my case, a particular expression I use should be equal to zero-or-one revisions.

This (ab)uses string literal syntax to parse out a range that is like a subset of Rust's range syntax; in particular unbounded endpoints like x.. or ..=y are not supported. Ideally the grammar would be expanded to handle this case more smoothly.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@thoughtpolice thoughtpolice requested a review from a team as a code owner September 25, 2025 04:04
@thoughtpolice
Copy link
Member Author

Note that I didn't take a stab at extending the parser yet to support range literals; the string-literal syntax is gross but I wanted to get the patch up first. But I can do that if we think we should (I suspect @yuja has thoughts :)

It turns out that the use case I had for `exactly()` was slightly more
subtle, and I need range support. In particular, usage of `exactly()`
in expressions used by `revsets.log-graph-prioritize` can and will
cause `jj log` to fail if the assertion fails; in my case, a particular
expression I use should be equal to zero-or-one revisions.

This (ab)uses string literal syntax to parse out a range that is like
a subset of Rust's range syntax; in particular unbounded endpoints like
`x..` or `..=y` are not supported. Ideally the grammar would be expanded
to handle this case more smoothly.

Signed-off-by: Austin Seipp <[email protected]>
@thoughtpolice thoughtpolice force-pushed the aseipp/push-nnxpwwlynqpr branch from 6dfc57e to 643c41b Compare September 25, 2025 04:18
@yuja
Copy link
Contributor

yuja commented Sep 25, 2025

My concern of reusing x..y syntax is that x..y in revset is kind of a half-open range of excluded/included pair, whereas integer range is included/excluded pair. I don't feel strongly whether it would be a good idea to introduce integer range of different semantics, though.

If we aren't sure, maybe we can add exactly(x, min, [max=min]) or exactly(x, min, [count=1]).

Another option is to add infallible version of exactly(x, n) which evaluates to none(), and use exactly(x, 0) | exactly(x, 1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants