Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: revset syntax to resolve an expression at an old operation #1283

Closed
ilyagr opened this issue Feb 18, 2023 · 7 comments
Closed

FR: revset syntax to resolve an expression at an old operation #1283

ilyagr opened this issue Feb 18, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@ilyagr
Copy link
Collaborator

ilyagr commented Feb 18, 2023

It would be nice to have something like xyz#a5b to represent the commit that the change xyz was at operation a5b. So, one could do jj log --at-op a5b and follow that up with jj restore --from xyz#a5b.

@ilyagr ilyagr added the enhancement New feature or request label Feb 18, 2023
@martinvonz
Copy link
Owner

xyz@a5b is another option, but then we'd probably need to replace the use of @ for branch@remote syntax.

@martinvonz
Copy link
Owner

If we choose @ for the operator, we'd probably also want to remove it from the allowed characters in an identifier:

jj/lib/src/revset.pest

Lines 15 to 19 in 92f9fe5

identifier_part = @{ (ASCII_ALPHANUMERIC | "_" | "@" | "/")+ }
identifier = @{
identifier_part ~ ("." | "-" | "+" ) ~ identifier
| identifier_part
}

@martinvonz
Copy link
Owner

But since we use @ for the working-copy commit, that's doesn't seem like a good idea :) So never mind, # seems much better

@ilyagr
Copy link
Collaborator Author

ilyagr commented Feb 18, 2023

I also don't particularly like #, but I haven't thought of a better option.

One ambiguity is whether @#abc6 should be the commit that was current at abc6 or the commit with the same change id as @ at abc6. I would probably want the former, but that would require exceptional treatment for revsets that include @.

Update On Discord, Martin suggested that the revset be expanded by first loading operation abc6 and then computing @ in that context. That would solve this problem.

@martinvonz martinvonz changed the title FR: revset syntax to specify a change id at an old operation FR: revset syntax to resolve an expression at an old operation Feb 19, 2023
@ilyagr
Copy link
Collaborator Author

ilyagr commented Feb 19, 2023

This would also be quite useful for branches.

@yuja
Copy link
Collaborator

yuja commented Feb 19, 2023

So expr#op will be the operator to evaluate expr within the environment at op. If we can't find a better operator character, we can try with a function syntax first.

yuja added a commit to yuja/jj that referenced this issue Apr 2, 2023
Since resolve_symbols() now removes Present(_) node, it make sense to
handle symbol resolution error there. That's why I added a "pre" callback
to try_transform_expression().

Perhaps, "operation" scope (martinvonz#1283) can be implemented in a similar way,
(but somehow need to resolve operation id and call repo.reload_at(op).)
yuja added a commit to yuja/jj that referenced this issue Apr 3, 2023
Since resolve_symbols() now removes Present(_) node, it make sense to
handle symbol resolution error there. That's why I added a "pre" callback
to try_transform_expression().

Perhaps, "operation" scope (martinvonz#1283) can be implemented in a similar way,
(but somehow need to resolve operation id and call repo.reload_at(op).)
yuja added a commit that referenced this issue Apr 3, 2023
Since resolve_symbols() now removes Present(_) node, it make sense to
handle symbol resolution error there. That's why I added a "pre" callback
to try_transform_expression().

Perhaps, "operation" scope (#1283) can be implemented in a similar way,
(but somehow need to resolve operation id and call repo.reload_at(op).)
@ilyagr
Copy link
Collaborator Author

ilyagr commented Aug 3, 2024

A related FR would be a "universal reflog", a way to see or use the "previous value" of something like "main@origin" as something like "main@origin#1". This would ignore any past operations that didn't change the value of "main@origin". (Of course, we'd need a different symbol or syntax if main@origin#1 treats 1 as an operation id. Or, perhaps we could use one of ^% for op id. % makes the most sense to me at the moment, not sure why).

I think filtering by revset could already be implemented as an option to jj op log (similarly to filtering by file for jj log), but that's a separate feature and would be more awkward to use.

@yuja yuja self-assigned this Sep 28, 2024
yuja added a commit to yuja/jj that referenced this issue Oct 9, 2024
This can be used in order to refer old working-copy commit, for example. If
we find it's useful, maybe we can add an infix syntax later.

Closes martinvonz#1283
yuja added a commit to yuja/jj that referenced this issue Oct 9, 2024
This can be used in order to refer old working-copy commit, for example. If
we find it's useful, maybe we can add an infix syntax later.

Closes martinvonz#1283
yuja added a commit to yuja/jj that referenced this issue Oct 11, 2024
This can be used in order to refer old working-copy commit, for example. If
we find it's useful, maybe we can add an infix syntax later.

Closes martinvonz#1283
@yuja yuja closed this as completed in f166fd0 Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants