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

2654 commits

Author SHA1 Message Date
Yuya Nishihara
fa045d632c revset: allow trailing comma
It's unlikely we would write multi-line function call in revset, but let's
allow trailing comma for consistency.
2023-02-07 23:19:36 +09:00
Yuya Nishihara
686c1fb522 templater: allow trailing comma
While rewriting the default log template, I find it's annoying that I have
to remove "," from the last line.
2023-02-07 23:19:36 +09:00
Yuya Nishihara
ba1c4f5fe5 cli: replace all $variable matches found in edit/merge-args 2023-02-07 18:32:57 +09:00
Yuya Nishihara
a1bfe33a08 cli: expand $left/$right parameters in merge-tools.<name>.edit-args
And set edit_args = ["$left", "$right"] by default.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
449e84d7ea cli: rename interpolate_mergetool_filename_patterns(), inline caller
I'll add string interpolation support to edit-args.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
baa67fe1db cli: make interpolate_mergetool_filename_patterns() simply work with strings
The assumption here is temp_dir wouldn't contain invalid utf-8 bytes. If it
can contain invalid bytes, maybe we can remove temp_dir from arguments, and
chdir(temp_dir) instead.

This unblocks the use of Regex. We could use regex::bytes, but it's way
more complex as we would have to go back and forth between str/OsStr and
bytes.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
d5f05b7897 cli: implement Default for MergeTool, do not override it with empty args
The default edit_args will be changed to ["$left", "$right"] to support
variable substitution without breaking the existing configuration too much.

The default merge_args could also be set if we could come up with something
meaningful.
2023-02-07 18:32:57 +09:00
Yuya Nishihara
2d17385d2e config: add merge-tools.<name>.edit-args to schema 2023-02-07 18:32:57 +09:00
Samuel Tardieu
605a39b84f jj new --insert-after 2023-02-07 09:16:48 +01:00
Samuel Tardieu
4119aa44a9 jj new --insert-before 2023-02-07 09:16:48 +01:00
Yuya Nishihara
cd164be762 templater: inline extract_entire_prefix_and_trimmed_tail() and simplify 2023-02-07 11:42:39 +09:00
Yuya Nishihara
ebf9887d65 templater: migrate shortest_prefix_and_brackets() over shortest() 2023-02-07 11:42:39 +09:00
Yuya Nishihara
3ccac9cda5 templater: rename shortest_styled_prefix() to shortest()
Now it is the true "shortest prefix" function with the default parameter,
so let's simply call it "shortest()".
2023-02-07 11:42:39 +09:00
Martin von Zweigbergk
fcda05c69b tests: reduce subprocessing in unique-prefix tests
The unique-prefixe tests are typically the slowest tests. Here's the
end of my `cargo nextest --workspace` output (from an arbitrary run,
not best-of-5 or anything):

PASS [   5.129s] jujutsu::test_log_command test_log_prefix_highlight_brackets
PASS [   5.220s] jujutsu::test_log_command test_log_prefix_highlight_styled
PASS [   8.523s] jujutsu::test_log_command test_log_prefix_highlight_counts_hidden_commits

These tests create 50-100 commits in a loop. I think much of it comes
from the subprocessing and/or the repeated loading of the repository
in the subprocesses. Rewriting them to use `jj duplicate` for creating
many commits at once speeds them up. Here are the timings after:

PASS [   2.323s] jujutsu::test_log_command test_log_prefix_highlight_styled
PASS [   2.330s] jujutsu::test_log_command test_log_prefix_highlight_brackets
PASS [   3.773s] jujutsu::test_log_command test_log_prefix_highlight_counts_hidden_commits
2023-02-06 12:32:23 -08:00
dependabot[bot]
52ff0ae9e6 github: bump cachix/install-nix-action from 18 to 19
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 18 to 19.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](daddc62a2e...5c11eae19d)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-06 15:26:46 +00:00
dependabot[bot]
9826f5ce9c cargo: bump serde_json from 1.0.91 to 1.0.92
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.91 to 1.0.92.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.91...v1.0.92)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-06 15:26:01 +00:00
Samuel Tardieu
6377b4f502 style: move unix-specific imports into unix section 2023-02-06 13:16:30 +01:00
Samuel Tardieu
f986415ef7 cargo: remove unused 'test-case' dev dependency 2023-02-06 13:14:43 +01:00
Martin von Zweigbergk
74bff5c916 doc: include diff format in config schema 2023-02-05 23:36:30 -08:00
Martin von Zweigbergk
9cdc202b39 cli: document diff format 2023-02-05 23:36:30 -08:00
Martin von Zweigbergk
8d3d89facc cli: rename diff.format to ui.diff.format
I felt that the config is too narrow to have it's own top-level [diff]
section, and I couldn't think of another good place to have it. I'm
happy to hear other suggestions.
2023-02-05 23:36:30 -08:00
Martin von Zweigbergk
f4374086b3 git_backend: return error when told to write commit without parents
There should be no other commits than the root commit without parents.
2023-02-05 22:52:23 -08:00
Martin von Zweigbergk
8c63fbc4ed git_backend: don't panic if told to write merge with root commit
I think the CLI currently checks that the backend is not told to write
a merge commit with the root as one parent, but we should not panic if
those checks fail.
2023-02-05 22:52:23 -08:00
Martin von Zweigbergk
2b2a9a36d7 git_backend: test conversion of parents, including root
We didn't seem to have any tests showing how we convert the set of
parents, and especially how we handle the root commit, so let's add
some.
2023-02-05 22:52:23 -08:00
Ilya Grigoriev
de163216c0 Templater: make shortest id functions default to 0 length
This makes them print the shortest unique prefix only.
2023-02-05 22:15:27 -08:00
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