-
Notifications
You must be signed in to change notification settings - Fork 346
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
Use shorter ID prefixes in configured revset #1603
Conversation
I plan to add `revsets.short-prefixes` and `revsets.immutable` soon, and I think `[revsets]` seems like reasonable place to put them. It seems consistent with our `[templates]` section. However, it also suffers from the same problem as that section, which is that the difference between `[templates]` and `[template-aliases]` is not clear. We can decide about about templates and revsets later.
I'd like to make the symbol resolution more flexible, both so we can support customizing it (in custom `jj` binaries) and so we can use it for resolving short prefixes within a small revset.
3d835fc
to
fc64b78
Compare
SGTM, besides the typo in the last sentence of the sixth commit message I do have a question related to the fourth commit as it will impact my PR(#1200). Is there a good pattern for the default |
fc64b78
to
1d5984d
Compare
I don't think it should impact your PR. Were you thinking that we'd implement |
No I didn't use the revset symbols, although it could've worked. But I restructured the PR to use // Similar to cmd_next, on my machine
let helper = ...;
let current_wc_id = helper.get_wc_id()?;
let parent = current_wc_id.parents().pop();
let all_ancestors = RevsetExpression::ancestors(&parent);
//... which will need to use the Resolver. |
Ah, I see. I think that should actually just use |
Thanks for clearing my concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
1d5984d
to
e983ba1
Compare
I would eventually want the `SymbolResolver` to be customizable (in custom `jj` binaries), so we want to make sure we always use the customized version of it. I left `RevsetExpression::resolve()` unchanged. I consider that to be for programmatically created expressions.
When creating `RevsetExpression` programmatically, I think we should use commit ids instead of symbols in the expression. This commit adds a check for that by using a `SymbolResolver` that always errors out.
I want to store some lazily calculated data associated with a repo. The data will depend on the user's config, which means it shouldn't live in the `ReadonlyRepo` itself. We could store it directly in `WorkspaceCommandHelper` - and I did that at first - but it's annoying and risky to remember to reset the cached data when we update the repo instance (which we do when a transaction finishes). This commit therefore introduces a wrapper type where we can store it. Having a wrapper also means that we can use `OnceCell` instead of more manually initializing it with a `RefCell`.
I would like to copy Mercurial's way of abbreviating ids within a user-configurable revset. We would do it for both commit ids and change ids. For that feature, we need a place to keep the set of commits the revset evaluates to. This commit adds a new `IdPrefixContext` type which will eventually be that place. The new type has functions for going back and forth between full and abbreviated ids. I've updated the templater to use it.
This prepares for adding callbacks to resolve these ids.
This is another step towards resolving abbreviated commit ids within a configured revset.
I'll reuse it there next.
I'll use this in `IdPrefixContext` soon.
For the support for shorter prefixes within a revset, we'll want to be able to check if an id is in the index.
In large repos, the unique prefixes can get somewhat long (~6 hex digits seems typical in the Linux repo), which makes them less useful for manually entering on the CLI. The user typically cares most about a small set of commits, so it would be nice to give shorter unique ids to those. That's what Mercurial enables with its `experimental.revisions.disambiguatewithin` config. This commit provides an implementation of that feature in `IdPrefixContext`. In very large repos, it can also be slow to calculate the unique prefixes, especially if it involves a request to a server. This feature becomes much more important in such repos.
This adds a config called `revsets.short-prefixes`, which lets the user specify a revset in which to disambiguate otherwise ambiguous change/commit ids. It defaults to the value of `revsets.log`. I made it so you can disable the feature by setting `revsets.short-prefixes = ""`. I don't like that the default value (using `revsets.log`) cannot be configured explicitly by the user. That will be addressed if we decide to merge the `[revsets]` and `[revset-aliases]` sections some day.
By passing the repo as argument to the methods instead, we can remove the `repo` field and the associated lifetime. Thanks to Yuya for the suggestion.
26474ba
to
6bfee4a
Compare
Checklist
If applicable:
CHANGELOG.md