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

2602 commits

Author SHA1 Message Date
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
Martin von Zweigbergk
c1799b27a6 cli: say "snapshot working copy" in the operation description
This is user-visible, but it didn't seem important enough to mention
in the changelog. I can easily be convinced that it should be.
2023-02-02 21:03:30 -08:00
Martin von Zweigbergk
6b7f8e5eab cli_util: rename commit_working_copy() to snapshot_working_copy() 2023-02-02 21:03:30 -08:00
Martin von Zweigbergk
b0a6493d20 cli: rename --no-commit-working-copy to --ignore-working-copy
We have moved from saying "committing the working copy" towards saying
"snapshotting the working copy". More importantly, the option also
means that we don't update the working copy at the end. I went with
the `--ignore-working-copy` name suggested by Ilya. I also updated the
documentation of the option.
2023-02-02 21:03:30 -08:00
Yuya Nishihara
45a018ec6b templater: report invalid argument count as error
We'll probably need a helper to extract N..M arguments, but let's revisit
it later.
2023-02-03 12:06:04 +09:00
Yuya Nishihara
baf911459f templater: report invalid argument type as error 2023-02-03 12:06:04 +09:00
Yuya Nishihara
4eff802d87 templater: report keyword/function/method name error 2023-02-03 12:06:04 +09:00
Yuya Nishihara
8653cc885a templater: wrap inner parsing functions with Result<T> 2023-02-03 12:06:04 +09:00
Yuya Nishihara
7090fa0374 templater: report syntax error, don't panic()
Even though the template syntax is experimental, panicking parser makes
it difficult to write tests. So let's add minimal error handling. The error
types are basically copied from the revset module.

I made write_commit_summary() fall back to the default template if user
template had syntax error. It should be better than reporting parse error
after e.g. "jj abandon" finished successfully.
2023-02-03 12:06:04 +09:00
Martin von Zweigbergk
1e48914c42 github: add reminder to update config schema in PRs
We have forgotten this many times already.
2023-02-02 16:03:53 -08:00
David Barnett
14982d750e (Minor fix) Don't request pager for config edit, only config list 2023-02-02 19:17:05 +01:00
David Barnett
8ee919dcbb Don't output implicit defaults from "config list"
Accept an --include-defaults arg to enable including those.

Listing a nonexistent name is no longer an error, but does output a
warning to stderr when no config entries match to explain why there's no
other output.
2023-02-01 19:49:57 -06:00
Yuya Nishihara
d6592573d0 templater: abstract Dynamic/LabelTemplate over labels type, unify them 2023-02-02 01:12:23 +09:00
Yuya Nishihara
1911734acc templater: add wrapper that turns template back to string property
I have no idea whether or not any template expressions are intentionally
allowed as a label, but it makes sense to write something like
'label("phase-" phase, ...)' (if we had a phase keyword.) So I decided to
add .into_plain_text() instead of stricter .try_into_string().
2023-02-02 01:12:23 +09:00
dependabot[bot]
a42ce8773c cargo: bump bytes from 1.3.0 to 1.4.0
Bumps [bytes](https://github.com/tokio-rs/bytes) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: bytes
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-01 15:20:46 +00:00
dependabot[bot]
bd5cbbdbaa github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from ce8f65846d7180d2ce63b1e74483d981800b9e22 to c758e63728211bd4acda6501cfa2a16c5c751fc4.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](ce8f65846d...c758e63728)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-01 15:19:38 +00:00