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

cli new: Allow --before/--after without a value to default to @ #4551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ilyagr
Copy link
Collaborator

@ilyagr ilyagr commented Sep 29, 2024

Without this, I find it a bit jarring that jj new works but jj new --before does not. By contrast, since jj rebase does not currently work, I don't think jj rebase --before should either.

Note that jj new --before @ another_revision is invalid, so jj new --before another_revision can only be parsed correctly in one way. I am slightly concerned that clap might forbids this in the future even in the cases where a human can tell there is no ambiguity, but I'm hoping for the best.

Checklist

If applicable:

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

@ilyagr ilyagr marked this pull request as ready for review September 29, 2024 22:15
@ilyagr ilyagr force-pushed the ig/newbefore branch 2 times, most recently from 77ef289 to 99b9e34 Compare September 29, 2024 22:23
Without this, I find it a bit jarring that `jj new` works but `jj new
--before` does not. By contrast, since `jj rebase` does not currently
work, I don't think `jj rebase --before` should either.

Note that `jj new --before @ another_revision` is invalid, so `jj new
--before another_revision` can only be parsed correctly in one way. I am
slightly concerned that `clap` might forbids this in the future even in
the cases where a human can tell there is no ambiguity, but I'm hoping
for the best.
@martinvonz
Copy link
Owner

Without this, I find it a bit jarring that jj new works but jj new --before does not.

I would not expect jj new --before to work. Maybe it's just because I'm used to Mercurial's argument parsing. Either way, I didn't think we have and existing flags with optional values, so I think we should think carefully before we add one. I assume it will only be possible to do it for commands that don't take any positional arguments, which limits the commands where we can use it even if we wanted to.

@ilyagr
Copy link
Collaborator Author

ilyagr commented Sep 30, 2024

By the way, jj new --before used to work before we added the ability to use both --before and --after in the same command, since it was a boolean flag back then. I used that often, and I still haven't gotten used to it going away. My sense of "jj new assumes @" is strong. I don't know whether I was the only one.

I do not propose we use these very often, but jj new seems pretty safe to me as I explained above and as the tests show. Still, I can understand it if people are worried, and perhaps I will get used to it eventually.

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