FR: Batch alias calls for undo/redo
Is your feature request related to a problem?
I have an alias that does multiple things at once. However, when I undo the last called action, it only reverts the last command in the alias. This is not the best UX.
Describe the solution you'd like
Would've been amazing to have all the actions, called from aliases, batched, so that undo/redo would batch revert/apply them, as if the alias was a single action indeed.
Describe alternatives you've considered
The only other option I see is to memorize how many times I need to undo/redo, or build a specific undo-something alias per something command, which is far from perfect
Alternative? : part of the alias could be op log to capture the ID of the current state and that is what you op revert to.
Alternative? : part of the alias could be
op logto capture the ID of the current state and that is what youop revertto.
It's nice to have an alternative, but still, this is far from perfect DX
I think "perfect DX" would be different in every situation.
This is also essentially asking for low-level transaction access, see previous discussions in #3428 and #6846 (in the latter there's a nice alias which you can copy for this).
This is also essentially asking for low-level transaction access, see previous discussions in #3428 and #6846 (in the latter there's a nice alias which you can copy for this).
Thank you, but this is not really what I am looking for
I think "perfect DX" would be different in every situation.
I think that it is "perfect DX" if you call a command and can undo it with ease. You don't wanna deal with op log, you don't wanna think of it in terms of a special case. You wanna call a command, undo, redo it and never think about it imperatively, only declaratively, as an atomic operation, no matter how much it actually does under the hood.
It's the same as what we have with bookmarks: I have a way to move the bookmark to the current changeId, but I have to specify a bookmark name manually for whatever reason, which is achievable, but painful, and therefore - not perfect. Luckily, this is something we can build alias for, but I wish we didn't have to.
Having things working out of box the way you expect them to work is "perfect DX"
How does your alias do multiple things at once? Using jj util exec?
Perhaps when we implement #3673, we should make those aliases be a single operation.
How does your alias do multiple things at once? Using
jj util exec?Perhaps when we implement #3673, we should make those aliases be a single operation.
Yep, like
push = ["util", "exec", "--", "bash", "-c", """
set -e
# Check if current commit has both description and changes
has_description=$(jj log -r @ --no-graph --color never -T 'description' | grep -q . && echo "yes" || echo "no")
# Use 'empty' template keyword to check if commit has changes
has_changes=$(jj log -r @ --no-graph --color never -T 'empty' | grep -q "false" && echo "yes" || echo "no")
if [ "$has_description" = "yes" ] && [ "$has_changes" = "yes" ]; then
echo "Current commit has description and changes, creating new commit..."
jj new
fi
# Get the bookmark from the parent commit directly
bookmark=$(jj log -r 'ancestors(@) & bookmarks()' -n 1 --no-graph --color never -T 'bookmarks' | sed 's/\\*$//' | tr -d ' ')
if [ -z "$bookmark" ]; then
echo "No bookmark found on parent commit"
exit 1
fi
echo "Moving bookmark '$bookmark' to parent commit and pushing..."
jj bookmark set "$bookmark" -r @-
jj git fetch
jj git push --bookmark "$bookmark" --allow-new
"""]
This FR is really similar to https://github.com/jj-vcs/jj/issues/6663.