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

808 commits

Author SHA1 Message Date
Yuya Nishihara
5ec56fb3e9 templater: inline build_method_call()
I don't think this function will grow to unmaintainable size, and I'm going
to add global function dispatcher there.
2024-03-16 10:28:19 +09:00
Ilya Grigoriev
0120cf994b external diff editor: move utility functions to a new file
This is preparation for #3292, which will use these functions. The main
goal is to merge the parts of #3292 that are likely to cause merge
conflicts with other PRs while I polish it up.
2024-03-15 12:30:37 -07:00
Ilya Grigoriev
d5a4891b49 external diff editor: extract functions to populate and delete JJ_INSTRUCTIONS
This will be reused for integration with the new `:builtin-web` diff editor in #3292.

`instructions-path_to_cleanup` is moved into DiffWorkingCopies.

DiffWorkingCopies: add instructions_path_to_cleanup
2024-03-15 12:30:37 -07:00
Martin von Zweigbergk
3bb9fd412a debug-tree: allow looking up tree by path and id, not just revision
Sometimes only a tree has been created, so we shouldn't require a
commit for `jj debug tree`.
2024-03-14 23:28:59 -07:00
Khionu Sybiern
3bbc3e5715 docs: add FAQ for why to use new-then-amend over edit 2024-03-14 11:32:53 -07:00
Khionu Sybiern
289b9bc71f cli: update help message for jj edit
This change updates the language of `jj edit`'s help message to be
more clear as to the nature of the command. It also adds a 
recommendation for a more idiomatic/safer workflow.
2024-03-14 11:32:53 -07:00
Yuya Nishihara
e3303efcf3 cli_util: inline WorkspaceCommandHelper::check_non_empty()
It's simple, and has no data dependency.
2024-03-14 23:51:21 +09:00
Yuya Nishihara
218b1c6c16 commit_templater: add self.immutable() method
I don't know how immutable revisions should be labeled by default, but users
can customize templates whatever they like.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
04d5f59cbb templater: do not rewrite non-argument errors raised from self methods
I'm going to add new "self.immutable()" method, which takes no arguments but
can fail if the configured revset is wrong.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
78104b5e82 cli: extract function that stringifies RevsetParseError 2024-03-14 22:59:43 +09:00
Yuya Nishihara
34eb446037 cli: remove CommandError dependency from revset_util::evaluate()
This function will be called from the templater.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
7dfe04134d cli: check invalid declaration of immutable_heads() alias earlier
I just wanted to remove CommandError from parse_immutable_expression(), which
will be called from the templater, but the new error message looks also better.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
8235e458ed cli: extract primitives for user revset parsing and evaluation
Some of them will be called directly from the commit templater which shouldn't
know WorkspaceCommandHelper. All parameters are passed as function arguments
instead of having a nicer wrapper struct. That's because some resources (e.g.
repo and id prefix context) are also used for different purposes, and it seemed
uneasy to introduce high-level abstraction satisfying all the use cases.
2024-03-14 22:59:43 +09:00
Yuya Nishihara
5806dbfd32 revset_graph: detach CompositeIndex, reimplement as RevWalk
For API consistency. It wouldn't practically matter unless we want to reuse
.iter_graph() in lazy event-driven GUI context.

I don't see significant performance difference:
- jj-0: original impl with look-ahead IndexEntry<'_> buffer
- jj-1: this patch

With dense graph
```
% hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1 \
  "target/release-with-debug/{bin} -R ~/mirrors/git --ignore-working-copy log -r.. -T ''"
Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/git --ignore-working-copy log -r.. -T ''
  Time (mean ± σ):      1.367 s ±  0.008 s    [User: 1.261 s, System: 0.105 s]
  Range (min … max):    1.357 s …  1.380 s    10 runs

Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/git --ignore-working-copy log -r.. -T ''
  Time (mean ± σ):      1.344 s ±  0.017 s    [User: 1.245 s, System: 0.099 s]
  Range (min … max):    1.313 s …  1.369 s    10 runs

Relative speed comparison
        1.02 ±  0.01  target/release-with-debug/jj-0 -R ~/mirrors/git --ignore-working-copy log -r.. -T ''
        1.00          target/release-with-debug/jj-1 -R ~/mirrors/git --ignore-working-copy log -r.. -T ''
```

With sparse graph
```
% hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1 \
  "target/release-with-debug/{bin} -R ~/mirrors/git --ignore-working-copy log -r'tags()' -T ''"
Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/git --ignore-working-copy log -r'tags()' -T ''
  Time (mean ± σ):      1.347 s ±  0.017 s    [User: 1.216 s, System: 0.130 s]
  Range (min … max):    1.321 s …  1.379 s    10 runs

Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/git --ignore-working-copy log -r'tags()' -T ''
  Time (mean ± σ):      1.379 s ±  0.023 s    [User: 1.238 s, System: 0.140 s]
  Range (min … max):    1.328 s …  1.403 s    10 runs

Relative speed comparison
        1.00          target/release-with-debug/jj-0 -R ~/mirrors/git --ignore-working-copy log -r'tags()' -T ''
        1.02 ±  0.02  target/release-with-debug/jj-1 -R ~/mirrors/git --ignore-working-copy log -r'tags()' -T ''
```
2024-03-14 10:07:19 +09:00
Martin von Zweigbergk
93f651d597 next/prev: make first line of help text consistent
This drops the trailing period for consistency with other commands,
and rephrases them a bit for consistency between each other.
2024-03-13 11:11:20 -07:00
Yuya Nishihara
a3839cdf47 commit_templater: allow extension methods to capture repo 2024-03-14 00:00:18 +09:00
Yuya Nishihara
9b42c81d6f templates: add missing "\n" to builtin "root" output 2024-03-13 23:29:27 +09:00
Martin von Zweigbergk
800f0f0347 squash: accept multiple --from revisions
Now you can do e.g. `jj squash --from 'foo+::' --into foo` to squash a
whole series into one commit. It doesn't need to be linear; you can
squash a bunch of siblings into another siblings, for example.
2024-03-13 05:21:05 -07:00
Martin von Zweigbergk
f3e35f1da4 description_utils: teach combine_messages() to handle more than two sources
I plan to teach `jj squash --from` to accept a revset as input.
2024-03-13 05:21:05 -07:00
Martin von Zweigbergk
2b8988c620 description_util: make combine_messages() not handle abandoned commit
I'm going to teach the function to support combining more than two
descriptions.
2024-03-13 05:21:05 -07:00
dploch
84118e1edd commit_templater: add an AnyMap for extensions to cache their own info 2024-03-12 16:52:49 -04:00
Aleksey Kuznetsov
6fd15dc7e5 graphlog: refactor out node symbols from GraphLog
Now as default and elided node symbols come from the config, the next logical
step is to use them directly bypassing GraphLog. Note that commands like `jj op
log` and `jj obslog` do not use the elided node symbol at all.
2024-03-12 08:25:58 +05:00
Martin von Zweigbergk
e579bbad0c log: enable synthetic elided nodes by default
We're early in the release cycle, so let's enable this feature and
test it for a while before the next release.
2024-03-11 10:08:28 -07:00
Martin von Zweigbergk
8a7ccb1177 log: add some documentation
The `jj log` command had basically no documentation. Let's at least
start adding some.
2024-03-11 10:08:28 -07:00
Martin von Zweigbergk
e9655dba13 move: deprecate the command
Per discussion in
https://github.com/martinvonz/jj/discussions/2882. `jj squash` now has
all the functionality.
2024-03-11 09:25:17 -07:00
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