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

2617 commits

Author SHA1 Message Date
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
Martin von Zweigbergk
60086100a1 cli: split up cmd_config() into one function per subcommand
This style matches our other commands, and will probably be helpful as
the `jj config` command grows.
2023-02-03 19:16:48 -08:00
Martin von Zweigbergk
db817c8dcd cli: extract types for ConfigSubcommand variants 2023-02-03 19:16:48 -08:00
Martin von Zweigbergk
86e1b39ef1 cli: remove unnecessary lifetime in validate_branch_names_exist()
The lifetime isn't in the output and doesn't seem to constrain the
inputs either, so I think it had no effect.
2023-02-03 19:16:48 -08:00
Martin von Zweigbergk
4bff2ca172 cli: split up cmd_branch() into one function per subcommand
The function was getting long, and the new structure matches our other
commands.
2023-02-03 19:16:48 -08:00
Martin von Zweigbergk
0d15a02281 cli: extract types for BranchSubcommands variants
This matches how the other commands are defined. It will also help
split up the large `cmd_branch()` function.
2023-02-03 19:16:48 -08:00
Martin von Zweigbergk
086398dd55 init: provide more info when workspace init fails
We classified all errors from initialization as "The target repo
already exists". That's incorrect when the error came from the
backend.
2023-02-03 14:49:59 -08:00
Yuya Nishihara
e2a5a14463 cli: use label() to highlight "working_copy" commit in log template
I think this is a proper way to label the working-copy commit. This also
fixes "jj obslog" output, but I don't think anyone would care.
2023-02-04 01:58:13 +09:00
Yuya Nishihara
e2eda9f72f templater: inline "current_working_copy" keyword
Maybe I didn't make this change before because the closure needs to capture
WorkspaceId by value. Since the inlined version looks pretty simple, let's
go forward to do that.
2023-02-04 01:58:13 +09:00
Samuel Tardieu
edfa03f017 config: add schema for git.push configuration entry 2023-02-03 16:04:37 +01:00
Samuel Tardieu
af9471e65c git fetch: accept several remotes
The "--remote" option can be repeated, and the "git.fetch" key
is now a list.
2023-02-03 16:04:37 +01:00
Samuel Tardieu
4550b9c481 git fetch: add tests 2023-02-03 16:04:37 +01:00
Martin von Zweigbergk
e161bedd11 cli_util: elide a lifetime 2023-02-02 21:03:30 -08:00