2112 Commits

Author SHA1 Message Date
Evan Mesterhazy
37992412b6 cli split: Recommend jj config set --user instead of --repo in deprecation warning
It only occurred to me after I rebuilt jj and actually had to run the command
that we should probably recommend a change to the user config instead of the
repo config.

#3419
2025-02-14 01:41:41 +00:00
Yuya Nishihara
0d2becbac3 templater: add stringify(x) function to call string methods on template
It's also useful to remove color labels from the inner template.
2025-02-14 00:54:03 +00:00
Evan Mesterhazy
d5d21643d5 cli split: Add a config option controlling how bookmarks move during splits
Currently, `jj split` moves bookmarks from the target revision to the second
revision created by the split. Since the first revision inherits the change id
of the target revision, moving the bookmarks to the first revision is less
surprising (i.e. the bookmarks stay with the change id). This no-implicit-move
behavior also aligns with how `jj abandon` drops bookmarks instead of moving
them to the parent revision.

Two releases from now, `jj split` will no longer move bookmarks to the second
revision created by the split. Instead, local bookmarks associated with the
target revision will move to the first revision created by the split (which
inherits the target revision's change id). You can opt out of this change by
setting `split.legacy-bookmark-behavior = true`, but this will likely be
removed in a future release. You can also try the new behavior now by setting
`split.legacy-bookmark-behavior = false`.

Users who have not opted into the new behavior via the config setting will see
a warning when they run `jj split` informing them about the change. The default
behavior be changed in the future.

The `jj split` tests for bookmarks are updated to run in all three configurations:

- Config setting enabled
- Config setting disabled
- Config setting unset


#3419
2025-02-13 21:45:56 +00:00
Evan Mesterhazy
b90e5af51c json schema: Fix bad indentation for jj fix settings
The fix settings weren't indented consistent with the rest of the settings,
causing them to appear in the redacted snapshot in the test_util_config_schema
test.
2025-02-13 02:37:19 +00:00
hkalbasi
272955f4fe templater: add .escape_json method to string 2025-02-12 22:17:30 +00:00
Ilya Grigoriev
e83b328f71 ui.rs: style, fixup to 8aa2916 2025-02-12 21:25:37 +00:00
Josh Steadmon
69050f31f4 config-schema: expand options for ui.editor, ui.diff.tool, and ui.pager
In addition to a single string, the `ui.editor` and `ui.diff.tool` options also
allow arrays of strings. `ui.pager` allows arrays of strings as well as a nested
table describing both the command and the environment.

Update config-schema.json to allow all of these types of values.

Fixes #5617
2025-02-12 20:43:17 +00:00
Ilya Grigoriev
a3647a6796 json schema: update some defaults to their modern values 2025-02-11 23:25:00 +00:00
Ilya Grigoriev
3f9e55ffee json schema: set schema version to draft-4, clarify taplo support
"$comment" is not officially supported by draft-4, but it is in newer
drafts, and JSON schema readers are supposed to skip fields that
are not known to them.
2025-02-11 23:25:00 +00:00
Ilya Grigoriev
dae1664ad3 json schema: fix color names failing validation
This makes the schema a bit less smart, but there's a good chance
`taplo` could not use "propertyNames" anyway because that comes
from a newer version of the schema than `taplo` officially supports
(see the child of this commit).

Fixes #5607
2025-02-11 23:25:00 +00:00
David Rieber
dd73b5ab7d bookmarks: First step to make target revision a required argument to bookmark create/move/set.
With this change a warning is shown if the user does not explicitly specify the target revision, but the behavior is unchanged (it still defaults to the working copy).
In the future the warning will be turned into an error. In other words, it will be required to specify target revision.

The bulk of the changes here are to prepare tests for the upcoming change, to make the transition easier.

For additional details please see:
* https://github.com/jj-vcs/jj/issues/5374
* https://github.com/jj-vcs/jj/discussions/5363
2025-02-11 22:21:19 +00:00
Martin von Zweigbergk
f291ac44db cli: add difftastic as diff tool
Difftastic is pretty popular tool. Let's add it as a diff tool so it's
easier to enable.
2025-02-11 18:00:01 +00:00
Martin von Zweigbergk
7b1820adba cli: sort tools in merge_tools.toml 2025-02-11 18:00:01 +00:00
Emily
77f54a267e git: enable subprocessing by default
Given the previously‐stated intention of making this default
for the 0.27 release, prepare for that decision ahead of time by
enabling subprocessing by default on trunk. This will help surface
any regressions and workflow incompatibilities and therefore give
us more information to decide whether to keep or revert this commit,
without inconveniencing any users who haven’t already opted in to
the bleeding edge.

Please feel free to revert without hesitation if any major issues
arise; this is not intended as a strong commitment to enable this
option for the next stable release if it turns out to not be ready. In
that case, it’s better that we learn that early on in the cycle,
rather than having to revert at the last minute or, worse, cutting
a stable release that we later find contains a serious regression.
2025-02-10 22:10:22 +00:00
Martin von Zweigbergk
1e25101cea
cli: status: replace "is clean" by "has no changes"
"The working copy has no changes" seems much easier to understand for
new users. Thanks to @Wilfred for the suggestion.
2025-02-10 08:01:50 -08:00
Martin von Zweigbergk
65dc6750e0 docs: move Git command table to a separate page
The table can be easy to miss in its current location.
2025-02-10 15:29:32 +00:00
Martin von Zweigbergk
ea10adfbd5 cli: delete unused variants of BuiltinToolError
Some variants became unused in bce8cb9.
2025-02-10 02:56:01 +00:00
Benjamin Tan
07c63ed182 cli: remove ui.allow-filesets configuration option
The "fileset" language has been enabled by default since v0.20.
2025-02-08 19:34:05 +00:00
Martin von Zweigbergk
9cab4d9a0b cli: describe how to set a config value with apostrophes
Apostrophes are not uncommon in e.g. `user.name`, so let's help the
user by providing examples.
2025-02-08 18:46:37 +00:00
avmikhailov
a16555f9af index: Return Result from heads
there are many ways to implement `heads` for your custom backend:
one involves calling `self.evaluate_revset` with a proper revset. 
However, it can return an error, but `heads` does not allow it.

In our implementation of the index backend we do exactly the above 
and we ended up with several unwraps which we are trying to avoid 
as it could potentially crash our prod jobs.

P.S. The same logic applies to many methods in this trait, but I am doing one at a time.
2025-02-07 13:45:47 +01:00
Jonathan Frere
42161257ca cli: op undo: show a warning when undoing an undo operation
One common issue that users run into with `jj undo` is that they expect
it to behave like an "undo stack", in which every consecutive `jj undo`
execution moves the current state further back in history. This is
(currently) an incorrect intuition - running multiple `jj undo` commands
back-to-back will only result in the previous non-undo change being
reverted, then un-reverted, then reverted, and so on.

This change adds a hint when the user runs `jj undo` multiple times
consecutively, suggesting that they may be looking for `jj op restore`,
which allows them to revert the whole state of the repository back to
a previous snapshot.
2025-02-07 08:27:16 +01:00
Ilya Grigoriev
4ba316d9f7 cli reference: fix jj git push link formatting
Currently, the rendering in
https://jj-vcs.github.io/jj/prerelease/cli-reference/#jj-git-push is
incorrect.

Fixup to 5b5a9e7
2025-02-06 17:35:20 -08:00
Josh Steadmon
975e1e1e24 templater: add optional ellipsis arg to truncate template functions
If an ellipsis arg is given to the truncate_* template functions, append (or
prepend) the ellipsis when the template content is truncated to fit the maximum
width.

Fixes #5085.
2025-02-06 11:34:33 -08:00
Jacob Hayes
4787dfef16
Fix backends.ssh.allowed-signers type in config-schema 2025-02-06 12:26:49 +07:00
Yuya Nishihara
5396138ed5 cli: update "only_path" warnings to say fileset expression instead of path
It's technically more correct.
2025-02-06 00:45:44 +00:00
Ilya Grigoriev
f60014f3ee built-in pager: allow configuring streampager options
This also changes the default to be closer to `less -FRX`. Since this
default last changed very recently in #4203, I didn't mention this in
the Changelog.

As discussed in https://github.com/jj-vcs/jj/pull/4203#discussion_r1914372214

I initially kept the config closer to streampager's (see
https://github.com/jj-vcs/jj/compare/main...ilyagr:jj:streamopts?expand=1), but
then decided to make it more generic, smaller, and hopefully easier to
understand.
2025-02-05 02:38:11 +00:00
Ilya Grigoriev
8aa29169ea pager: refactor pager config (no-op)
In the future, we could consider adding a few more
special configs, e.g. `:pagerenv` that strictly uses
the `PAGER` environment variable, and `:unix` that
mimics Git's algorithm of trying `PAGER`, defaulting
to `less`, and setting `LESS`.
2025-02-05 02:38:11 +00:00
Yuya Nishihara
891fe085a6 templater: add DiffStats type to provide raw stats values
I originally considered adding `stats() -> DiffStats` which returns an
unprintable object, with deprecation of `.stat(width)` in favor of
`.stats().<method_to_render>(width)`. However, I couldn't find a good name for
the rendering function. This patch instead made the width parameter optional. I
think that's good because template language doesn't have to be overly strict.

Closes #4154
2025-02-05 00:31:16 +00:00
Yuya Nishihara
b9aef59f0d diff: extract DiffStats type and calculate() function
This will help write template based on diff.stat() result. #4154

show_diff_stats() isn't reimplemented as DiffStats method because I think
DiffStats can be moved to jj-lib.
2025-02-05 00:31:16 +00:00
Yuya Nishihara
7c2d9f2878 diff: map read error of materialized file to BackendError
io::Error in this context means write!(formatter, ..) failed, whereas this is an
error reading file content from the backend.
2025-02-05 00:31:16 +00:00
Yuya Nishihara
7a66122778 diff: rename struct DiffStat to DiffStatEntry
I'm going to add Vec<DiffStatEntry> wrapper as DiffStats.
2025-02-05 00:31:16 +00:00
Yuya Nishihara
e85644994a diff: accumulate diff stat numbers separately
Total aadded/removed counts will be provided as DiffStats methods. This change
might result in slightly bad perf, but that wouldn't matter in practice.
2025-02-05 00:31:16 +00:00
Yuya Nishihara
2bef93bbbe diff: do not format diff stat paths early
This helps extract pure computational part from show_diff_stat(). I'm going to
add DiffStats template type.
2025-02-05 00:31:16 +00:00
Josh Steadmon
227eccefdb templater: add pad_centered template function
Add a new pad_center function that centers content within a minimum
width. If an odd number of fill characters is required, the trailing
fill will be one character longer than the leading fill.

Fixes #5066.
2025-02-04 18:16:20 +00:00
Yuya Nishihara
832e7b3522 cli: squash: use draft description template to generate editor content
Closes #5559
2025-02-04 06:05:58 +00:00
Yuya Nishihara
3cf6b3ca9d cli: split combine_messages() to two parts
Editor template will be rendered by caller.
2025-02-04 06:05:58 +00:00
Yuya Nishihara
e85a5c44cd rewrite: move description handling from squash_commits() to caller
This allows caller to reborrow tx.repo() to render description template. It
also matches the documented behavior.
2025-02-04 06:05:58 +00:00
Martin von Zweigbergk
834b0f195b cli: bookmarks: don't show Git hint in non-Git repos
Noticed while importing the latest version into the Google repo (some
of our tests failed).
2025-02-03 23:46:05 +00:00
Yuya Nishihara
7898eb9f82 git: split function that queries remote default branch, call only when needed
With git.subprocess = true, it's more important to skip unneeded remote
operations. Each remote command may involve user intervention if authentication
requires manual step.

This change also means that the remote connection is no longer reused in git2
impl. I think the added cost is acceptable. The git2 impl will hopefully be
removed soon, and the remote branch name is needed only when cloning new repo.
2025-02-03 03:43:11 +00:00
Yuya Nishihara
fc7ac4c0bf revset: extract helper that formats remote symbol
I'll add a few more callers.
2025-02-03 01:31:04 +00:00
Yuya Nishihara
5be25bc8cf parser: use backtick to quote name or expression in error message
I don't have any preference about quoting styles, but it looks weird if an
escaped symbol is surrounded by double quotes.
2025-02-03 01:31:04 +00:00
Vincent Ging Ho Yim
193191cc35 rebase: fix grammar in doc comments 2025-02-02 13:44:25 +00:00
Jakob Hellermann
cfe5915c33 cli: complete: complete revset alias symbols for revisions 2025-02-01 17:16:01 +00:00
Jakob Hellermann
f7429f2254 cli: complete: add dynamic completions for -T template aliases 2025-02-01 16:58:46 +00:00
Yuya Nishihara
658cd3e0fd git: resolve git2::Repository internally in GitFetch::new()
git2::Repository will be removed from the subprocess code path.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
9bf29accc2 git: resolve git2::Repository internally in push_updates()
git2::Repository will be removed from the subprocess code path.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
fd76b44d55 cli: transform GitFetch/PushError globally 2025-02-01 11:04:38 +00:00
Yuya Nishihara
27e7672a3b git: store bad pattern object in GitFetchError::InvalidBranchPattern
This helps add From<GitFetchError> impl.
2025-02-01 11:04:38 +00:00
Jakob Hellermann
d212becdba cli: complete: use null Ui to prevent writing warnings into completions
E.g. when the user doesn't have the default command set, you don't want
to get
```
Warning: Cannot define an alias that overrides the built-in command 'log'
```
printed on every completion.
2025-02-01 08:37:22 +00:00
Jakob Hellermann
d7c887c424 cli: add ability to construct null Ui without any output 2025-02-01 08:37:22 +00:00