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

783 commits

Author SHA1 Message Date
Martin von Zweigbergk
e6ef217d90 squash: learn --from/--into flags
This was proposed by @Brixy in
https://github.com/martinvonz/jj/discussions/2882 a while ago. There
seems to be pretty strong consensus that it's a good idea.

I've copied the added test cases from `test_move_command.rs`, just
replacing `move` by `squash`, `--to` by `--into`, and deleting the
test of a no-arg invocation (`jj move` fails, `jj squash` does not -
it defaults to squashing into the parent).
2024-03-11 09:25:17 -07:00
Martin von Zweigbergk
93c1a8079f squash: leverage helper extracted from jj move
This patch makes `jj squash` us the helper I just extracted from `jj
move`. I had a to add a few small features to it for that.

The `test_squash_command.rs` test changed in a few cases where we do a
partial squash. After this patch, we include the rebased child in the
count of rebased descendants. That seems reasonable and consistent
with partial squash/move further than 1 generation.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
2e3939df1c squash: fail on merge commits before failing on immutable commits
This is just a little step towards reusing the helper I just extracted
from `jj move`. I had to update `test_immutable_commits.rs` because it
would otherwise fail because of the merge rather than failing because
of the immutable commit.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
ce44d46583 squash: make -r argument optional in clap
I'm soon going to make `jj squash` accept either `-r` or
`--from/--to`, which means `-r` will then be optional. This patch
prepares for that already, since it also simplifies the code a little
(and improves it so we warn if the user does `jj squash -r @
nonexistent`).
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
e1997f6c9a move: record both source and destination as predecessors
This matches what we do for `jj squash`, whether it's a
full or partial move.

I didn't add a test since we're planning to deprecate `jj move`, and
this will soon be tested via the `jj squash` tests.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
018a871ce9 move: extract bulk of logic to function for reuse by jj squash 2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
7f101c4023 move: don't use transient commit in operation description
The `destination` variable we use when creating the operation log may
have been replaced earlier in the code. I think this was a regression
when I moved the setting of the description from `start_transaction()`
to `finish_transaction()` a while ago.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
4d42604913 git_backend: write trees involved in conflict in git commit header
We haven't used custom Git commit headers for two main reasons:

1. I don't want commits created by jj to be different from any other
   commits. I don't want Git projects to get annoyed by such commit
   and reject them.

2. I've been concerned that tools don't know how to handle such
   headers, perhaps even resulting in crashes.

The first argument doesn't apply to commits with conflicts because
such commits would never be accepted by a project whether or not they
use custom commit headers. The second argument is less relevant for
conflicted commits because most tools will be confused by such commits
anyway.

Storing conflict information in commit headers means that we can
transfer them via the regular Git wire protocol. We already include
the tree objects nested inside the root-level tree, so they will also
be transferred.

So, let's start by writing the information redundantly to the commit
header and to the existing storage. That way we can roll it back if we
realize there's a problem with using commit headers.
2024-03-10 20:51:05 -07:00
Martin von Zweigbergk
ea5a208ca5 cli: make *Args::tool fields non-public, except for DiffFormatArgs
Probably just a bad copy&paste.
2024-03-10 20:37:44 -07:00
Martin von Zweigbergk
6d78d92d91 cli: move jj amend/unamend aliases to config
The `amend/unamend` aliases exist for smoothen onboarding for
Git/Mercurial users; I don't think we should recommend that users use
them, so I think it's fine if users override them as they
like. Therefore, I think they belong in the config.
2024-03-09 22:43:50 -08:00
Anton Älgmyr
099f06bf71 Add configuration options for node symbols in the graphs. 2024-03-09 21:16:58 +01:00
Yuya Nishihara
a224d0f172 repo_path: show more detailed error if filesystem path failed to parse
This should address both use cases:
 1. If from_relative_path() is directly called, the error says ".." shouldn't
    be included in the (normalized) relative path.
 2. If parse_fs_path() is used, the error message contains paths relative to
    cwd. #3216
2024-03-09 11:01:43 +09:00
Yuya Nishihara
6498a0cf8a cli: propagate type error of "ui.default-command" 2024-03-08 23:57:59 +09:00
Martin von Zweigbergk
663e35255f cli: move jj co alias to config file, so it can be overridden
This way users can override `jj co` to mean `jj new` if they want to
get rid of the warning.
2024-03-07 09:46:34 -08:00
dploch
b4c4d91190 cli_util: support multiple cli arguments for ui.default-command 2024-03-07 09:34:18 -05:00
Martin von Zweigbergk
4d5d5c4ac2 tests: avoid deprecated jj co 2024-03-06 10:19:46 -08:00
Martin von Zweigbergk
1ee6b595a8 cargo: upgrade chrono from 0.4.34 to 0.4.35 2024-03-06 09:20:23 -08:00
Yuya Nishihara
4cb457eddb cli: leverage TypedValueParser::map() to implement RevisionArg parser
I just found there's a utility for that.
2024-03-07 00:36:19 +09:00
Yuya Nishihara
4dfded2ab7 cli: move join_message_paragraphs() to description_util 2024-03-07 00:33:28 +09:00
Aleksey Kuznetsov
38d14eafe2 cli: enrich the error about required template value with a hint
Several `jj` commands accept `--template <TEMPLATE>` argument. When the argument
is empty, `jj` will show the list of defined template aliases.
2024-03-06 08:12:40 +05:00
Yuya Nishihara
8c0f6a53c5 cli: colorize output of "config list" 2024-03-06 11:38:57 +09:00
Yuya Nishihara
7ca6744432 cli: add "config list --template" support
There's a caveat: "jj config list -Tname" will concatenate all names in a
single line. That's correct but useless. We might want some option or config
knob to complete missing "\n". This also applies to "log --no-graph".
2024-03-06 11:38:57 +09:00
Yuya Nishihara
56f1b36990 templater: unimplement Default for TestTemplateEnv
It was Default just because the implementation could be derived at that point.
Using Default no longer makes sense.
2024-03-06 11:38:57 +09:00
Yuya Nishihara
4c62f46c03 templater: leverage GenericTemplateLanguage in tests 2024-03-06 11:38:57 +09:00
Yuya Nishihara
d0168199f0 templater: add general-purpose template engine for value types
This serves the role of the formatter in Mercurial, but the provided features
are rather restricted compared to mercurial.formatter. That's because both
implementation language "Rust" and jj's template language are statically typed.

The current implementation works well for simple commands like "config list -T",
but it might be not okay for "branch list -T". If we implement branch templating
by using the generic mechanism, the commit summary part would have to be
evaluated as a separate template:

  -T 'branch_name ++ target_commit_summary' (target_commit_summary: Template)

instead of

  -T 'branch_name ++ commit_summary(target_commit)' (target_commit: Commit)

where the branch template language is a superset of the commit template
language.
2024-03-06 11:38:57 +09:00
Thomas Castiglione
fed682a430 tests: fix some failures on windows due to a missing TEMP environment variable 2024-03-05 15:16:38 +08:00
Anton Älgmyr
38b27de8e3 Add --context flag for diffs.
Allows specifying the number of lines of context to show around diffs.
The logic was already in place, just some plumbing was needed.
2024-03-05 07:48:23 +01:00
Yuya Nishihara
59a61a26d9 cli: reuse commit summary template and formatter in a loop
The performance wouldn't matter, but the new code doesn't look bad either.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
749ef4584d templater: inline commit/operation_templater::parse(), add command helper fns
I'm going to add generic templating support for basic value types, and
"jj config list -T" will use CommandHelper::parse_template().
CommandHelper::load_template_aliases() is made private instead.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
e82527857d cli: inline parse_commit_summary_template(), cache template text instead
This will help deduplicate template parsing functions. We don't care about the
cost of config.get_string(), but I don't want to copy the config key to every
caller.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
101e48d4a2 templater: extract language constructors
commit/operation_templater::parse() will be inlined soon.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
e1669f08fa templater: add helper function that does parse() + build()
This could be a provided method of the TemplateLanguage trait, but it's
unlikely that this method would have to be customized by implementors. And
I'm going to add thin wrapper method to CommandHelper, so no users would
write language.parse(..) anyway.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
26cce214cb templater: relax "L: TemplateLanguage" bounds to not require sized object
Just spotted while toying around with TemplateLanguage methods. The language
object is passed by reference, so it doesn't have to be Sized.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
81b5e6997c templater: add "pub" to operation template types and wrap fns in commit template
I'm going to split commit/operation_templater::parse() into two parts, and
the first half will be Commit/OperationTemplateLanguage::new(..). This patch
also makes CommitTemplateLanguage::wrap_() functions public because extension
methods should be able to return property of these types.
2024-03-05 12:12:34 +09:00
dploch
4847fedb33 commit_templater: make various attributes accessible to extensions 2024-03-04 19:59:41 -05:00
Yuya Nishihara
2817e30fc6 cli: ensure child processes are wait()ed on I/O error 2024-03-05 09:23:15 +09:00
Evan Mesterhazy
a09ee4b9a3 Make URLs in docs hyperlinks
`cargo doc` complains that two URLs aren't actually links:

```
warning: this URL is not a hyperlink
  --> lib/src/fsmonitor.rs:66:6
   |
66 | /// (https://facebook.github.io/watchman/). Requires `watchman` to already be
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://facebook.github.io/watchman/>`
   |
   = note: bare URLs are not automatically turned into clickable links
   = note: `#[warn(rustdoc::bare_urls)]` on by default

warning: `jj-lib` (lib doc) generated 1 warning (run `cargo fix --lib -p jj-lib` to apply 1 suggestion)
 Documenting jj-cli v0.14.0 (/Users/emesterhazy/oss/github.com/martinvonz/jj/cli)
 Documenting testutils v0.14.0 (/Users/emesterhazy/oss/github.com/martinvonz/jj/lib/testutils)
warning: this URL is not a hyperlink
    --> cli/src/cli_util.rs:2077:41
     |
2077 | /// To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.
     |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.>`
     |
     = note: bare URLs are not automatically turned into clickable links
     = note: `#[warn(rustdoc::bare_urls)]` on by default

warning: `jj-cli` (lib doc) generated 1 warning (run `cargo fix --lib -p jj-cli` to apply 1 suggestion)
```

This commit fixes the warnings by making the watchman URL a hyperlink and by
disabling the lint for the jj-cli error. Disabling the link is the right thing
to do because the comment is captured by clap and printed when `jj --help`
runs and any markdown formatting like `<>` is passed through.
2024-03-04 16:05:42 -05:00
Yuya Nishihara
7ce25f8408 cli: add --tool=<name> option to diff/merge editing commands
I didn't add e2e tests to all commands, but the added tests should cover
diff_editor/diff_selector/merge_editor() calls.

Closes #2575
2024-03-04 01:33:43 +09:00
Yuya Nishihara
4a47cba319 merge_tools: add Diff/MergeEditor constructors that look up tools by name
The tool name is parsed in the same way as diff_util::diff_formats_from_args().
2024-03-04 01:33:43 +09:00
Yuya Nishihara
0f42c56b5c merge_tools: box external tool variant to minimize stack size
The ExternalMergeTool struct has four 24-byte fields plus one bool. It could
be shrunk by dropping Vec/String capacity, but the resulting type would still
be bigger compared to the default Builtin variant.
2024-03-04 01:33:43 +09:00
Ilya Grigoriev
96bf190234 Nightly clippy fixes
There are a few additional warnings because of
https://github.com/rust-lang/rust-clippy/issues/12377, which is a
nightly-only bug that will hopefully be fixed.
2024-03-02 18:19:14 -08:00
Evan Mesterhazy
2f7b15b7b1 Add documentation comments for operation, transaction, and view types 2024-03-02 15:35:41 -05:00
Yuya Nishihara
f76830ab12 cli: translate last-minute EPIPE internally in handle_command_result() 2024-03-03 01:11:46 +09:00
Yuya Nishihara
ed1d2fde27 cli: move handle_command_result() to command_error module, make it less public
I don't think extensions would have to use this function, so made it pub(crate).
2024-03-03 01:11:46 +09:00
Yuya Nishihara
97024e5be4 cli: extract CommandError and helper functions to new module
The cli_util module is big enough to slow down Emacs, so let's split it up.
This change is an easy one.
2024-03-03 01:11:46 +09:00
Martin von Zweigbergk
4b1948c38e cli: don't use "check-out" as a verb (because it's not) 2024-03-02 06:59:09 -08:00
Yuya Nishihara
85586854f2 cli: add thin wrapper that runs --interactive diff editor conditionally
I considered inlining tx.select_diff(), but that looked a bit cryptic because
the arguments orders are reasonably different. This thin wrapper will help
enforce the common interactive editing behavior.
2024-03-02 23:33:45 +09:00
Yuya Nishihara
5df7a42915 merge_tools: move "ui.diff-instructions" to CLI and config/misc.toml
There are no users of this option in jj-lib. Let's simplify it.
2024-03-02 23:33:45 +09:00
Yuya Nishihara
b118e2f208 merge_tools: inline edit_diff() into DiffEditor::edit() 2024-03-02 23:33:45 +09:00
Yuya Nishihara
5cc89dde57 merge_tools: capture base_ignores and "ui.diff-instructions" by DiffEditor
For the same reason as the previous commit. The editor has nothing to be done
with the transaction.
2024-03-02 23:33:45 +09:00