-
Notifications
You must be signed in to change notification settings - Fork 357
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: Fix inconsistencies in how subcommands handle revision and path args #2554
Comments
I'm not generally a huge fan of "argument that changes the behavior of the following arguments", unless I can convince myself that it's a mode selector for the entire command. So something like I worry that something like Maybe it'd be fine once I got used to it, but I don't know of prior art for this style of "something that looks like a flag changes the behavior/interpretation of things that look like positional args". Actually I guess I have one example: |
The main reason hg and subsequently jj use positional args for paths is for shell expansion (like Clap allows non-positional args to have multiple values, and in my experience revsets are used way more often that paths - so now Having Again, I would honestly be happy with whatever as long as it is consistent, currently we only have a band aid of |
I know |
So based on that clap documentation, if I wrote Maybe this really indicates that there should be a |
I think the problem is that flags taking multiple values aren't so common (or at least, I'm not used to be.) It would be also a bit weird if |
Initially I wanted |
Eh, maybe I worked with fancy rust apps using clap more, makes perfect sense to me 🙃 Well, your example would happen rarely (and log should probably print a little hint that revset "baz" matched no commits), while |
We have to enclose revset expressions in quotes anyways pretty quickly when they have parentheses. Isn't it fine to force users to write Supporting shell expansion seems like a pretty niche feature. I would rather have |
It's not that hg and jj support shell expansion themselves, it's that by using positional arguments, they allow the shell to do it. For example, so if you run |
@martinvonz Sorry, I didn't state/justify my assumptions. Git will expand I would much prefer that we support glob patterns in I assume there is some rare workflow where you really want your glob expansion to match an untracked file because you really want to traverse the history of that file in the past when it was tracked, and also there are multiple files matching the glob pattern... and I don't feel it's worth optimizing for that. Should this FR be a discussion? We might benefit from semi-threaded replies. |
I don't have any conclusion in mind, but here are a few thoughts.
Shells can support fancier expansions, though I suppose we could reimplementing them. I do think I believe some users will get confused about the difference between I discovered that https://docs.rs/glob/latest/glob/struct.Pattern.html does support One weird, but maybe workable, alternative would be:
This could be combined with the idea of implementing some simple (or not so simple) globbing in |
Sentence cut off here?
Yes, in my ideal setup, you would have to write
(or simply
I think it would be good to not have positional arguments for such commands, but I don't agree that we should support variadic |
Note that positional revset is good (and we won't have -r variadic, just 1, probably even just leave the |
Path parsing will be migrated to parse_union_filesets(), but I haven't decided how we'll go forward: a. migrate everything to fileset b. require flag like "-e FILESET" (note -p conflicts with log -p) c. require flag like "-e FILESET" and deprecate positional PATHs jj-vcs#2554 d. require prefix like "set:FILESET" (not consistent with -r REVSET) I'm currently dogfooding (a). It works for me, but I don't use exotic file names that would require quoting in zsh. jj-vcs#3239
Sorry about the delay.
Mercurial does have glob expansion, but you need to prefix with
I agree that supporting globs in patterns is useful. My point was just that by requiring |
Path parsing will be migrated to parse_union_filesets(), but I haven't decided how we'll go forward: a. migrate everything to fileset b. require flag like "-e FILESET" (note -p conflicts with log -p) c. require flag like "-e FILESET" and deprecate positional PATHs #2554 d. require prefix like "set:FILESET" (not consistent with -r REVSET) I'm currently dogfooding (a). It works for me, but I don't use exotic file names that would require quoting in zsh. #3239
A simple solution might be Removing all positional path arguments in favor of explicit |
My proposal is that every command that works with a revset and an optional list of paths should have the following form:
jj subcommand revset* (-p path+ | -r revset+ | other-args)*
Here the first revset is an optional repeating positional arg, followed by (potentially) interleaved -p/--path(s) and -r/--revisions arguments, I described it with a pseudo-regex here.
This way, any of the following is valid:
jj log
jj log rev
jj log rev1 rev2
jj log -r rev
jj log rev -p path1 path2
jj log -r rev -p path1 path2
jj log -p path1 path2 -r rev
jj log -p path1 -r rev -p path2 path3
jj log rev1 rev2 -p path1 path2
jj log rev -r rev2 rev3
jj log -p path1 -r rev -p path2 -r rev2
Another way to describe it is that we consume "positional" args to be either a revset or a path depending on the state, which is initially "accept as revset", which can be switched to "accept as path" by-p
and back to "accept as revset" by-r
(or technically any other non-positional arg) - and also-p
or-r
are not allowed at the end.Forget about it, there's no stateful flags in reality 🙃
If command doesn't work with paths, we just dont have them, and now it's similar to how we have
unused_revision: bool
flag in some places (except it's not allowed at the end now too).This should cover most commands, actually, all of them that work with commits I guess.
Multiple revsets also don't make sense for all commands - for those we can just check and error out - or we can join them by
|
and then check if they resolve to a single commit.Note that something like
jj new a b
should work, but ifa
diverges we must passall:
to signify that we're sure we want to merge a divergent branch or whatever that is and also addb
into the mix - basically we don't want unexpected (where it matters, e.g. log is ok) revision resolutions withoutall:
.The main thing everything should be consistent :)
The text was updated successfully, but these errors were encountered: