ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

2629 commits

Author SHA1 Message Date
Ilya Grigoriev
f076fae9b5 Document the fact that jj rebase accepts multiple -d
It was already mentioned towards the end of the introductory text, but that's
easy to miss.

This also clarifies the doc for `--allow-large-revsets`.
2023-02-05 22:07:28 -08:00
Yuya Nishihara
7bb7d2bd35 cli: rename FullCommandArgs to CommandNameAndArgs
Per discussion in #1198.
2023-02-06 15:03:08 +09:00
Yuya Nishihara
eb95b31b78 cli: split command name and args by FullCommandArgs
If FullCommandArgs is renamed to CommandNameAndArgs, the meaning of .args()
will get fuzzy. This also clarifies that the name part exists even if the
source command string is empty.
2023-02-06 15:03:08 +09:00
Ilya Grigoriev
9cc536e9e0 Mention --allow-large-revsets in hint when one revset resolves to multiple revisions 2023-02-05 21:22:18 -08:00
Ilya Grigoriev
db148af019 Move resolve_destination_revs into mod.rs
It's not very general.
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
4183c69238 Refactor & rename resolve_base_revs to extract the more general function
This extracts the more general `resolve_mutliple_nonempty_revsets_flag_guarded`
out of `resolve_base_revs`. This function should be useful for `rebase -s`,
etc.

`resolve_base_revs` is renamed to `resolve_destination_revs`; that's simply a
better name for it. It is also quite specific to the `new` and `rebase -d`
commands.  It will be moved out of general utilities in the next commit
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
1c6c6dbccc jj rebase -d and jj new: Allow several commits per argument with --allow-large-revsets
Eventually, we should be able to rely on `jj op restore` and the `--allow-large-revsets`.
argument should likely be removed. This is a temporary measure until we figure
out https://github.com/martinvonz/jj/issues/922 and the like.

Fixes https://github.com/martinvonz/jj/issues/571
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
d153ced8ba cli_util: Make resolve_base_revs use IndexSet
This will make deduplication easier in the next commit.
The error message becomes slightly less informative, unfortunately.
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
4268c80c84 Refactor and rename rewrite_multiple_rewriteable_revsets to be more general
We'll soon need that functionality without the checking for rewriteable
part.
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
159c474e2c Move resolve_multiple_rewriteable_revsets to cli_utils.rs 2023-02-05 21:22:18 -08:00
Ilya Grigoriev
8c4fa90e2e Add test for error on jj rebase -d large_revset + test of repeats 2023-02-05 21:22:18 -08:00
Ilya Grigoriev
8c1a5539ad cli: Include revset in hint for resolve_single_rev
The revset is already printed in the error message, but it's easy to miss since
the error message is in different color.
2023-02-05 21:22:18 -08:00
Ilya Grigoriev
5fb17925eb jj log: option to specify preferred id length
The new option is `ui.log-id-preferred-length`. Setting it to 6
is quite convenient for the `jj` repo, for example.

Screenshot: https://user-images.githubusercontent.com/4123047/216535699-ad1e2ac8-73dd-44be-b28a-ebdebc00c63c.png
2023-02-05 21:18:42 -08:00
Ilya Grigoriev
b87facff7a Templater: Give short id function a total_len argument
This will be tested in the next commit.
2023-02-05 21:18:42 -08:00
Ilya Grigoriev
58828803d4 Templater: Give shortest id functions a total_len argument. 2023-02-05 21:18:42 -08:00
Ilya Grigoriev
1d1fe77cc8 Update outdated config-schema.json for the unique-prefixes option 2023-02-05 21:18:42 -08:00
Yuya Nishihara
097d3a0e6c templater: add generic wrappers for Option<TemplateProperty>
Option<P> allows us to embed optional argument property in tuple.

    let maybe_arg = maybe_pair.map(|pair| parse(...))?;
    chain_properties((self, maybe_arg), |_: &(Context, Option<_>)| ...)

For one optional argument, we can instead switch the property functions:

    if let Some(pair) = maybe_pair {
        let arg = pair.map(|pair| parse(...))?;
        chain_properties((self, arg), |_: &(Context, _)| ...)
    } else {
        chain_properties(self, |_: &Context| ...)
    }

If we have various combinations of optional arguments, using Option<P> would
be better.
2023-02-06 12:03:56 +09:00
Yuya Nishihara
13d9dc4460 cli: allow to set ui.diff/merge-editor arguments inline
For stock merge-tools, having name -> args indirection makes sense. For
user-specific settings, it's simpler to set command name and arguments
together.

It might be a bit odd that "name with whitespace" can be parsed differently
depending on the existence of merge-tools."name with whitespace".
2023-02-06 11:28:40 +09:00
Yuya Nishihara
78b63c8137 cli: check value type of ui.diff/merge-editor config 2023-02-06 11:28:40 +09:00
Yuya Nishihara
6f4522e34a cli: move MergeArgsNotConfigured to ExternalToolError
Even though this is an error specific to merge operation, I think it's
rather a tool-level error than conflict resolution.
2023-02-06 11:28:40 +09:00
Yuya Nishihara
2f23d0dd10 cli: specify ui.diff/merge-editor keys statically
This helps me grep source code.
2023-02-06 11:28:40 +09:00
Yuya Nishihara
0163bba347 cli: add basic tests for diff/merge-editor configuration 2023-02-06 11:28:40 +09:00
Samuel Tardieu
39226fc127 style: use helper instead of buiding UserError by hand 2023-02-05 20:23:29 +01:00
Yuya Nishihara
a7e2c06068 config: move src/commands/config-schema.json back to src/
I think this is an oversight of moving things into commands/ module.
2023-02-05 19:02:54 +09:00
Yuya Nishihara
5bfecf112a templater: add parsing rule for integer literal, add i64 property
This will be used as a parameter of id.shortest*() methods. For now, only
decimal literal is supported, and there's no unary negate operator.
"0"-prefix is disallowed because it looks like an octal number.

I don't think we would want multiple integer types in the template language,
so I chose i64 as the integer type of reasonable width.
2023-02-05 17:21:54 +09:00
Yuya Nishihara
353d915326 templater: disallow identifier starting with number 2023-02-05 17:21:54 +09:00
Yuya Nishihara
fe8c41bbd7 templater: extract primary rule, inline maybe_method instead 2023-02-05 17:21:54 +09:00
Yuya Nishihara
e4fbb1fe83 templater: extract "function" parsing to function
It's getting bigger.
2023-02-05 17:21:54 +09:00
Yuya Nishihara
9a5a88238b templater: fix handling of method chaining of parenthesized expression 2023-02-05 17:21:54 +09:00
Yuya Nishihara
16a744fe18 templater: make internal parse_template_str() return expression
An "Expression" object is more useful while writing tests.
2023-02-05 17:21:54 +09:00
Yuya Nishihara
5342d2cfb7 templater: implement string.contains() method as example 2023-02-05 11:53:11 +09:00
Yuya Nishihara
54de6168f2 templater: implement TemplateProperty for tuples up to 4-ary
A method call with arguments will be combined to (self, args...) tuple.
Unary tuple is useless, but is implemented for consistency.

This tuple_impls! macro is based off the serde one as the Rust core one
requires unstable feature.
2023-02-05 11:53:11 +09:00
Yuya Nishihara
a4be118981 templater: check number of method arguments 2023-02-05 11:53:11 +09:00
Yuya Nishihara
28c1989257 templater: add helper to extract argument pairs 2023-02-05 11:53:11 +09:00
Yuya Nishihara
945f9c1552 templater: pass parse_keyword() down to method parsing functions
It's needed to parse argument expressions.
2023-02-05 11:53:11 +09:00
Yuya Nishihara
db172aa7c9 templater: process property composition by parse_<type>_method()
This prepares for adding method arguments support. Since a method argument
should be evaluated in the surrounding scope, its type will be
'TemplateProperty<I>', not 'TemplateProperty<J>' for the receiver type 'J'.
Then, the receiver of type 'TemplateProperty<I, Output = J>', and arguments
of type 'TemplateProperty<I, Output = Pn>' will be composed to an input of
type 'TemplateProperty<I, Output = (J, Pn...)>'.

wrap_fn() is removed since it's only useful for nullary methods, and we
no longer need Box<dyn> to abstract the return value.
2023-02-05 11:53:11 +09:00
Yuya Nishihara
bdf809c6c3 templater: do not turn method arguments into iterator by caller
parse_<type>_method() will need args_pair.as_span() to report invalid
argument error.
2023-02-05 11:53:11 +09:00
Yuya Nishihara
5072469eca templater: extract generic parsing functions
We'll probably need a better abstraction, but a parameterized keyword
function is a good first step. This unblocks the use of parse_term() for
context-less properties (or literals). I'm going to add a proper support
for context-aware method arguments, but literals can be parsed without it.

parse_keyword() closure is passed by reference to avoid infinite expansion.
2023-02-05 11:53:11 +09:00
Yuya Nishihara
1b78fb5b5d templater: add shorthand for Result<T, TemplateParseError>
This will appear in "impl Fn(..) -> .." and we can't alias it.
2023-02-05 11:53:11 +09:00
Martin von Zweigbergk
24bc34a0e9 cli: make hints cyan instead of blue
It's hard to read dark blue on black, at least with iTerm2's default
color scheme. Cyan makes it much more readable. That's the color
`cargo` uses. We could also consider coloring only the "Hint:" part
like `cargo` does. For errors, `cargo` colors the "Error:" part red
and uses bold/bright white for select parts of the message.
2023-02-04 11:16:34 -08:00
Martin von Zweigbergk
0625a26121 cli: fix typo in "rewriteable"
It's apparently spelled without the second "e".
2023-02-04 11:16:17 -08:00
Yuya Nishihara
1972eccad1 cli: leverage separate() function to concatenate log template fields 2023-02-04 15:19:02 +09:00
Yuya Nishihara
fbd6657e3f cli: omit log template separator if author.email() is empty 2023-02-04 15:19:02 +09:00
Yuya Nishihara
eb3aeb42dc cli: do not include separator in labeled log template fields 2023-02-04 15:19:02 +09:00
Yuya Nishihara
13b5661094 templater: add separate(sep, contents...) function
This is a copy of Mercurial's separate() function.
2023-02-04 15:19:02 +09:00
Yuya Nishihara
84ee0edc51 templater: add Template::has_content() to filter out empty expressions
This allows us to insert a separator between non-empty template fragments.
Since FormattablePropertyTemplate::has_content() needs to extract
a TemplateProperty, using this function means the property function will
be evaluated twice, one by .has_content() and later by .format(). The cost
is basically the same as 'if(prop, " " prop)'.
2023-02-04 15:19:02 +09:00
Yuya Nishihara
5850575d53 templater: add separate variants for exact/range argument count errors
I believe this isn't a good abstraction, but I need to add one more variant
for "at least n arguments" error. A stringified count like "2 to 3" could be
embedded in an error variant, but I don't think it's good idea to build error
message in that way.
2023-02-04 15:19:02 +09:00
Yuya Nishihara
1883d62805 tests: extract helper that renders colored commit template 2023-02-04 15:19:02 +09:00
Martin von Zweigbergk
0e90cdedbc cli_util: always run custom global-args-processing function
The way I added support for processing custom global arguments - by
using the existing `dispatch_fn` - meant that it wouldn't be run if
`CliRunner::add_global_args()` was called before
`CliRunner::add_subcommand()` and the custom subcommand wasn't
run. That's clearly not what I intended. This commit fixes that by
adding a separate list of functions for processing global args.
2023-02-03 22:18:51 -08:00
Martin von Zweigbergk
0ea8da064d cli_util: make CliRunner builder functions mutate self
It's easier to mutate `self` than to create a new instance. It does
increase the risk of forgetting to update a field when adding a new
field or a new function, so maybe that's why @yuja did it this way?
2023-02-03 22:18:51 -08:00