Commit graph

2907 commits

Author SHA1 Message Date
Ilya Grigoriev
d9c031c35b cli completion: remove non-functional diff editors/formatters
Follows up on  https://github.com/jj-vcs/jj/pull/7009
2025-07-19 18:09:01 +00:00
Ilya Grigoriev
7dadc13458 merge-tools.toml: disable diff editing and/or viewing with tools that don't support it
This partially addresses #4549 together with the parent commits. A further
step would be to make it clearer to the users why a tool is disabled. For
now, this information is added to the comments of `merge-tools.toml`
2025-07-19 03:39:16 +00:00
Ilya Grigoriev
fedbc3017f cli merge tools: allow setting diff-args=[] to disable diff formatting with a tool
Not setting `diff-args` is equivalent to `diff-args=["$left",
"$right"]`, which I also documented here.

I couldn't decide whether the new error should be part of
`DiffRenderError`, `DiffGenerateError`, or `MergeToolError`. Since the
treatment of diff formatters is already very different from other merge
tools, I just made it a CommandError for now.
2025-07-19 03:39:16 +00:00
Ilya Grigoriev
dae9ce7677 cli merge tools: allow setting edit-args=[] to disable diff editing with a tool 2025-07-19 03:39:16 +00:00
Ilya Grigoriev
1b161321e3 cli merge tools: rename internal DiffTool type to DiffEditTool
Without this, it's easy to mistakenly think that a `DiffTool`
could be (or perhaps has to be) a diff formatting tool.
2025-07-19 03:39:16 +00:00
Ilya Grigoriev
c6338a5594 cli merge_tools.toml: add diff viewing config for diffedit3 and vscode
They are not the most useful diff formatters, but they function, so
I thought it's better than making this an error in the following commits.

I also tried to clarify the comments a bit.
2025-07-19 03:39:16 +00:00
Josh Steadmon
d7fa04f510 templater: add parents() method for Operation
Add a parents() method for `Operation` template objects, copied from the
implementation for `Commit`s.

The test case added in test_operations.rs was heavily inspired by
test_commit_templates.rs:test_log_parents().

Fixes #6979
2025-07-18 17:16:09 +00:00
Kaiyi Li
f1f1556731 local working copy: add support for EOL conversion 2025-07-17 15:36:28 +00:00
Kaiyi Li
74fb5a6096 working copy: pass UserSettings to WorkingCopyFactory
... so that later `TreeState` can query the EOL settings on
construction.
2025-07-17 15:36:28 +00:00
Evan Martin
d9b0a42a85 cli: make diff --stat fill available width
Previously, the computation for the available display width
included a padding constant, but this value was then used as
an upper bound for the width of the bar.  This meant the bar
would never fill the available screen width.
2025-07-17 02:03:16 +00:00
Evan Martin
228ea38aeb tests: make diff --stat test filenames clearer
Change the file names in the test to reflect a bit about what they're testing,
and add a test for a file that is a binary->binary modification.
2025-07-17 02:03:16 +00:00
Martin von Zweigbergk
59de83a84a cli: move desc and st aliases to config
We generally prefer to define aliases in the default config so users
can override them.
2025-07-15 06:11:28 +00:00
Hubert Głuchowski
8ec0196aca status: collapse entirely untracked directories
This change makes status collapse directories which don't contain any
tracked files into one line so that large untracked directories don't
clutter up the status with loads of files.

For example for a tree like this:
```
T src/main.rs
U src/lib.rs
U tmp/a.txt
U tmp/b.txt
```

Previously the status would display these untracked paths:
```
? src/lib.rs
? tmp/a.txt
? tmp/b.txt
```

With this change it now looks like this:
```
? src/lib.rs
? tmp/
```
2025-07-14 19:41:27 +00:00
Ilya Grigoriev
13d747c807 cli completion: complete diff tools such as :git and :summary 2025-07-14 05:29:09 +00:00
Ilya Grigoriev
1161e95640 cli completion: complete --tool args for merge tools
Includes diff tools, diff editors, and merge editors.
2025-07-14 05:29:09 +00:00
Stephen Jennings
9b86159789 fix: prepend file name to stderr output
To distinguish stderr output from different invocations of fix tools,
write the file name to stderr before writing the output from the fix
tool.
2025-07-12 05:35:34 +00:00
Stephen Jennings
8c12452f97 fix: write complete stderr output at once from fix tools
Fix tools often emit information on stderr for the user to see. Since
fix tools are run in parallel and stderr is unbuffered, this information
can be jumbled together. This seems to happen especially frequently on
Windows.

This change locks stderr before writing to it so the stderr output from
a tool is written all at once.
2025-07-12 05:35:34 +00:00
Yuya Nishihara
ea3c1791a6 revset: soft-deprecate "all:" modifier syntax 2025-07-11 17:15:26 +00:00
Yuya Nishihara
6c8f6e9744 cli: allow "large" revsets by default
Since divergent/conflicted symbols no longer resolve to multiple revisions, it's
less scary to allow "large" revsets than before.

The config doc is removed because it's largely duplicated from the revsets doc,
and the config key will be removed.

#6016
2025-07-11 17:15:26 +00:00
Yuya Nishihara
5666f4ac23 cli: complete: use diff template instead of parsing copied/renamed paths
I don't think the original implementation handles sorting and filtering of the
renamed source paths correctly, so I've added explicit .sort() at the end.

Fixes #6922
2025-07-10 12:42:08 +00:00
Yuya Nishihara
99e877b6a2 tests: add a few more copied/renamed files to completion sample 2025-07-10 12:42:08 +00:00
Yuya Nishihara
e4f0942f26 index: replace external users of CompositeIndex 2025-07-10 12:40:13 +00:00
Bryce Berger
a471eb9cb1 template/revset: mention tree-sitter grammar in pest file 2025-07-10 09:54:27 +00:00
Remo Senekowitsch
5804bf95d0 bookmark rename: fix hint for pushing the rename
The --all flag previously also pushed deleted bookmarks. This was
changed and now --deleted is always required to push deleted bookmarks.
2025-07-09 18:37:22 +00:00
Joaquín Triñanes
4fb5014ba7 config-schema: add missing commit_trailers setting 2025-07-08 13:06:56 +00:00
Ilya Grigoriev
083fdaac60 build.rs: separate commit ids if compiling at a merge commit
This makes the `test_version` test failure when run at a merge commit
less confusing. The test could be fixed, but I'm not sure it's worth it,
as we probably don't want to release a version of `jj` compiled at a
merge commit.

Now, if `jj` is compiled at a merge commit, this would print:

```
$ jj --version
jj 0.31.0-fb10a78cb359d52c0eda518a42ab07f117909004-ff9c9d0d8b4e929843eb683709fc1717645796df-99e035c5054e71906d7293ed98b542a9055057ef
```

Admittedly, this is a bit of a quick hack, but I've been confused by
`jj --version` output when compiled at a merge commit enough times
to want it.

Prior art: https://github.com/jj-vcs/jj/pull/6311 and
https://github.com/jj-vcs/jj/pull/4033 both pick one commit id hash
to print. I think I prefer printing all of them, even if it will fail
tests at a merge commit. After this commit, the failure will at least
be easy to understand.

However, if we prefer to merge one of the others, I'm OK with that too.
2025-07-08 02:38:21 +00:00
Yuya Nishihara
39bb608a43 cleanup: remove &'static lifetime that can be implied 2025-07-08 01:52:44 +00:00
Pavan Kumar Sunkara
c038ef4bc3 workspaces: Add templating support to workspace list 2025-07-07 19:14:07 +00:00
Martin von Zweigbergk
af621c7dbe cleanup: replace once_cell::sync::Lazy by std::sync::LazyLock
This makes it a little easier to switch away from the `once_cell`
crate once `get_or_try_init()` has been stabilized.
2025-07-07 14:24:25 +00:00
Yuya Nishihara
be094ef76e revset: don't resolve symbol expression to multiple revisions
It's surprising that a symbol expression may be resolved to multiple revisions,
and that's one of the reason we require all: modifier in some places. Let's make
a symbol resolution fail in that case so we can deprecate the all: syntax.

The new error hints are a bit less informative, but I don't want to implement
ad-hoc formatting for resolve_some_revsets_default_single(). The user will have
to review the graph anyway in order to resolve divergence/conflicts.

Closes #5632
2025-07-07 14:11:29 +00:00
Ilya Grigoriev
784408f46f cli fetch: put all not-found branches into one warning
I often use the following command, sometimes in a loop over different repos.
It's annoying when it prints several lines of warnings. One line should
be enough.

```sh
jj git fetch && jj git fetch --remote upstream --branch main  --branch master \
   --branch 'glob:gh-readonly-queue*' --branch 'glob:ig/*'
```
2025-07-05 19:40:45 +00:00
Ilya Grigoriev
be27966214 clippy: nightly clippy fix
I find the result harder to read correctly, but it doesn't seem worth
maintaining a clippy exception for.
2025-07-05 02:48:36 +00:00
Martin von Zweigbergk
3211e9c05c merged_tree: make diff_stream() sort foo before foo/bar
For most callers, the special sorting of directories before paths for
directory->file transitions is not needed. This patch changes
`diff_stream()` to not do that, and instead adds a new method
specifically for that behavior. Only `local_working_copy` uses it.
2025-07-04 01:12:18 +00:00
Yuya Nishihara
ea8aa1e17c index: don't preserve commits not referred to by operations/views
In this implementation, we assume that predecessor commits created by old jj are
reachable from at least one of the historical views. However, there are a couple
of commands which create transitive predecessors. For example, "jj squash" into
grandparent will rebase a rewritten source, so the pre-rebase source commit
won't be visible to any views. To work around the problem, all immediate
predecessors of historically visible commits are also preserved.

Note that this change should be considered forward-incompatible change. The
stored commits may have unreachable predecessors once we run "jj op abandon &&
jj util gc".

WalkPredecessors::flush_commits() doesn't need to guard against unreachable
commits. I was wondering whether values (or old ids) of op.commit_predecessors
map should be preserved, and I decided to keep both keys and values. It's nice
that we can get rid of index.has_id() calls when we drop support for legacy
commit.predecessors.
2025-07-03 09:06:21 +00:00
Yuya Nishihara
68ead52c5c hex_util: roll our own decode/encode_hex() functions
Since we have "reverse hex" functions, it's easy to implement the same set of
functions for "forward hex". I believe our implementation is slower than
highly-optimized versions provided by e.g. faster-hex, but we don't use hex
encoding/decoding where the performance matters.
2025-07-02 01:56:40 +00:00
Yuya Nishihara
f1b29510d3 object_id: rename HexPrefix::new() to ::try_from_hex() for consistency 2025-07-02 01:56:40 +00:00
Yuya Nishihara
3a8b83d1fc cli: git-push: make "change" bookmark names templated
Someone asked this on Discord, and it's useful if the bookmark name should
include e.g. issue number (which can be extracted from commit description.)
2025-07-02 01:55:59 +00:00
Yuya Nishihara
9e53d31b48 cli: git-push: collect "change" bookmark names by separate loop
This avoids borrowing issue in the next commit. I also inlined
short_change_hash() as I'm going to replace one of them with templating.
2025-07-02 01:55:59 +00:00
Yuya Nishihara
483e5a6205 cli: complete: do not prioritize bookmarks by git.push-bookmark-prefix
I'm going to reimplement "git.push-bookmark-prefix" as a template, and it would
be weird that we had to extract a prefix from template expression.

https://github.com/jj-vcs/jj/pull/6847#discussion_r2173283275
2025-07-02 01:55:59 +00:00
Yuya Nishihara
e3b6599424 templater: rename PlainText pseudo type to Stringify
Since the goal of this pseudo type is to get a String value, it can be called a
ToString or Stringify. I chose the latter because Stringify sounds similar to
Serialize (verb), and I don't want to rename the internal functions to
.try_into_to_string().

https://github.com/jj-vcs/jj/pull/6840#discussion_r2173076763
2025-07-01 00:30:22 +00:00
Yuya Nishihara
8db40c7fa2 revset: add change_id/commit_id(prefix) predicates
Basically, these functions work in the same way as bookmarks()/tags(). They
restrict the namespace to search the specified symbol, and unmatched symbol
isn't an error. One major difference is that ambiguous prefix triggers an error.
That's because ambiguous prefix should logically select all matching entries,
whereas the underlying functions don't provide this behavior. It's also unclear
whether we would want to get all matching commits by commit_id(prefix:'').

#5632
2025-06-30 14:38:50 +00:00
Yuya Nishihara
4a9fcb0d15 templater: inline expect_<construct>_with() parsing helpers
There aren't many callers, and it was inconsistent that some callers didn't
attach alias traces to diagnostic messages.

The stripped-down expect_<construct>() functions also attempt to unwrap aliases
for consistency reasons. This is redundant, but should be cheap. If there were
callers who don't need to reinterpret a string literal, they wouldn't have to
use catch_aliases() block at their call sites.
2025-06-30 13:54:57 +00:00
Yuya Nishihara
11806dee95 templater: extract helper functions that handles alias expansion stack
I think the non-recursive implementation is easier to follow.
2025-06-30 13:54:57 +00:00
Gaëtan Lehmann
a59607db25 squash: allow to squash into the sources
This way it becomes possible, when squashing multiple commits, to specify
from which commit we keep the change-id, without needing to provide
multiple --from parameters.
For example, for a set of commits from x to z, with y somewhere in the
middle, before we had to run

  jj squash --from x::y- --from y+::z -into y

to squash x::z into y. Now we can

  jj squash --from x::z -into y

Squashing into the same change as the source becomes a no-op.

On the implementation side, we just make sure the destination commit is
not in the source commits.
2025-06-29 12:54:40 +00:00
Scott Taylor
bcde9ca728 revset: add parents(x, depth) and children(x, depth)
Resolves #3337.
2025-06-29 03:51:19 +00:00
Yuya Nishihara
a561fab59c templater: add PlainText/Serialize pseudo types for documentation purpose 2025-06-28 00:40:14 +00:00
Yuya Nishihara
019ef25db4 templater: add renderer.format_plain_text() for convenience 2025-06-28 00:40:04 +00:00
Yuya Nishihara
c489186bbe cli: print non-UTF-8 paths transparently on Unix 2025-06-27 10:19:50 +00:00
Yuya Nishihara
8d846c864e workspace: leverage path_from/to_bytes() helper 2025-06-27 10:19:50 +00:00
Yuya Nishihara
d62052938c revset: normalize and simplify type error messages
These messages were inconsistent, and I think "expression of" is redundant.
2025-06-27 01:29:11 +00:00