Commit graph

3106 commits

Author SHA1 Message Date
Yuya Nishihara
46d5555be4 cleanup: leverage trait upcasting, delete as_any*()
This patch also adds .downcast*() wrappers to prevent misuse of as &Any casting.
The compiler wouldn't help detect &Arc<T> as &Any, for example.

https://blog.rust-lang.org/2025/04/03/Rust-1.86.0/#trait-upcasting
2025-09-20 01:22:47 +00:00
Yuya Nishihara
8982af2a6b cli: pass typed reference to check_local_disk_wc()
This at least enables compile-time check for the working copy object.
2025-09-20 01:22:47 +00:00
Yuya Nishihara
78c09fc9e4 ui: switch to std::io::pipe()
MSRV is now 1.88.
2025-09-19 09:41:32 +00:00
Yuya Nishihara
65d15d7ef6 cli: help: remove details from short description of "gerrit upload"
I also removed "If true," because --dry-run is a flag taking no value.
2025-09-19 09:41:26 +00:00
George Christou
1a0e868e5c template: add string replace method 2025-09-19 09:01:07 +00:00
Martin von Zweigbergk
0ea94d07f4 gerrit: fix a misplaced comment in test 2025-09-19 07:06:04 +00:00
Theo Buehler
47d912d166 docs: document gerrit.default-branch, fix gerrit.default-remote
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The former wasn't mentioned in the doc comment, the latter with an
incorrect name, which I found confusing.
2025-09-19 01:56:58 +00:00
Austin Seipp
419bd51496 cargo: bump MSRV to 1.88
1.90 was just released, so this seems reasonable, and it finally lets us
use let-chains. This includes all the clippy fixups too, and some small
changes suggested by Ilya.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-19 01:03:21 +00:00
Matt Stark
1a4a74f7a0 gerrit: Fix bug where only the head commit would get a Change-Id 2025-09-19 00:45:03 +00:00
Daniel Luz
4fd2c446dd complete: ignore shell quotes when parsing command line
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
When completion functions are called in bash and zsh, quoted arguments
are passed exactly as they are typed, including shell quotes, and
clap_complete currently does not attempt to normalize this behavior.

For example, if the user types:

    jj diff -f 'trunk()' <TAB>

std::env::args() will be equivalent to:

    ["jj", "diff", "-f", "'trunk()'", ""]

To accurately capture the revset, the quotes need to be stripped.

This workaround handles the most common cases that work consistently
across shells, rather than going for maximum accuracy.
2025-09-17 02:00:43 +00:00
Reuven Lazarus
b5f86417cb upload: ensure unique prefixes in gerrit_change_id 2025-09-16 19:36:01 +00:00
Reuven Lazarus
ff3cf64e78 templates: ensure unique prefixes in format_gerrit_change_id_trailer
Gerrit's web UI (like jj) recognizes unique ID prefixes, so a reference
like `I1234cdef` in a commit message or a review comment becomes a
hyperlink to the referenced change. Currently, every jj-produced change
begins with `I6a6a6964`, which makes that less useful. This moves the
fixed `6a6a6964` component to the end, so the prefix is unique.

Closes #7500.
2025-09-16 19:36:01 +00:00
Philip Metzger
6b4b2c7daf cli bookmark: un-deprecate default revset arguments
This is mostly a revert of dd73b5ab7d. It closes #5374, as feedback on
the issue has shown that many longtime and new users dislike it. Martin
himself also mentioned that he wants to walk back this deprecation.

Co-authored-by: Remo Senekowitsch <remo@buenzli.dev>
2025-09-16 17:11:38 +00:00
Martin von Zweigbergk
a9384e88ca gerrit: minor cleanups 2025-09-16 15:37:13 +00:00
Austin Seipp
35ad063b85 cli: basic jj gerrit upload implementation
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This implements the most basic workflow for submitting changes to Gerrit,
through a verb called 'upload'. This verb is chosen to match the gerrit
documentation (https://gerrit-documentation.storage.googleapis.com/Documentation/3.12.1/user-upload.html).

Given a list of revsets (specified by multiple `-r` options), this will parse
the footers of every commit, collect them, insert a `Change-Id` based off the jj change-id (if one doesn't already exist), and then push them into the given remote.
It will then abandon the transaction, thus ensuring that gerrit change-IDs do not appear in jj.

Because the argument is a revset, you may submit entire trees of changes at
once, including multiple trees of independent changes, e.g.

    jj gerrit upload -r foo:: -r baz::

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-16 02:15:09 +00:00
Yuya Nishihara
84c7f5d562 cli: diff: pass $width parameter to external diff tools
Closes #4161
2025-09-16 01:49:21 +00:00
Yuya Nishihara
f4fe07bb7f cli: merge-tools: simply build map of owned substitution variables
I'm going to add $width parameter, and it would be tedious if we had to allocate
places to store formatted strings separately.
2025-09-16 01:49:21 +00:00
Yuya Nishihara
91e5befe3e cli: diff: pass left/right trees as array to reduce number of arguments 2025-09-16 01:49:21 +00:00
Yuya Nishihara
d9552c4313 cli: merge-tools: make check_out_trees() get store from MergedTree
All callers pass left_tree.store() anyway.
2025-09-16 01:49:21 +00:00
Martin von Zweigbergk
5e6e2359dd simplify-parents: call RevsetExpression::descendants() using method syntax 2025-09-16 00:43:41 +00:00
Yuya Nishihara
8cd43d169f merge: remove Default from MergeOptions
Some checks failed
binaries / Build binary artifacts (push) Has been cancelled
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
2025-09-14 03:55:09 +00:00
Yuya Nishihara
79a2a777b8 local_working_copy: remove Default from TreeStateSettings
It should be better for external merge tools explicitly disable EOL conversion
and fsmonitor.
2025-09-14 03:55:09 +00:00
Martin von Zweigbergk
b6c5c23bf1 completion: match files in revision for file list
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-12 18:06:03 +00:00
Martin von Zweigbergk
92bc6e4447 merged_tree: move MergeOptions to tree_merge
`MergeOptions` isn't currently used directly in either module but it's
more closely related to `tree_merge`. It's possible we will want to
pass it into `ConflictIterator`, however.
2025-09-12 16:11:13 +00:00
Yuya Nishihara
af4fe21452 files, tree: make same-change conflict resolution configurable
I have no idea if we can change the default, but maybe we can conditionally
disable the same-change rule to get rid of hacks in squash_commits(), etc.?

resolve_file_executable() doesn't respect the Store configuration. I'm not sure
if that's the right choice, but it seemed better to accept duplicated change
than falling back to executable=false.

#6369
2025-09-11 13:14:28 +00:00
Yuya Nishihara
0376bcfdc6 files: rename FileMergeOptions to MergeOptions, move to merged_tree
I'll add same-change rule parameter to disable A+(A-B)=A resolution. Since tree
merging involves content merging, file-level parameters should also be included
in the "tree" merge options. We could add a nested options type, but I don't
think we'll add an option that applies only to tree-level merging. So this patch
unifies these options types as MergeOptions.
2025-09-11 13:14:28 +00:00
Remo Senekowitsch
0a965918d1 cli metaedit: fix --update-author if author was unset
The commit builder prepared by `rewriter.reparent()` already updates the
author to the currently configured one in case the author was previously
unset. When the new author is compared to `commit_builder.author()`,
they compare as equal, making it look like the author didn't change.
If that was the only change that would've happened, the commit is not
rewritten at all, meaning the commit author stays unset. This is fixed
by comparing the new author to the actual author of the old commit.
2025-09-11 13:03:43 +00:00
Stephen Jennings
08f2e21ebf config: add platforms conditional configuration
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Adds a new `--when.platforms` condition for including configuration.
This is useful when someone syncs their dotfiles across machines.

The values for `platforms` are defined by `std::env::consts::FAMILY` and
``std::env::consts::OS. Any Unix-family platform can be specified using
the value `"unix"`, or individual operation systems can be chosen with
`"linux"`, `"macos"`, or `"windows"`.

Example:

```toml
ui.pager = ["less", "-FRX"]

[[--scope]]
--when.platforms = ["windows"]
ui.pager = ["C:/Program Files/Git/usr/bin/less.exe", "-FRX"]
```
2025-09-11 06:33:20 +00:00
Ian Wrzesinski
5f6f938a24 working_copy: Move FsmonitorSettings to TreeStateSettings and add test method to update settings
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-10 09:47:19 +00:00
Austin Seipp
8e2820f130 templates: add hyperlink alias
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-09 09:18:12 +00:00
Yuya Nishihara
9589bec37a files: add option to resolve conflicts word by word
This option affects emptiness of commits, which means indexed changed files can
become stale on configuration change. This problem can also be said for changes
in the diff algorithms, so I don't think we need a logic to invalidate index on
config change.

I have this patch for months, and it seems working good at least for Rust
sources.

Closes #17
2025-09-09 03:44:16 +00:00
Yuya Nishihara
e9e9c6f150 files: introduce stub of FileMergeOptions
I'll add word-by-word merging flag. Since we need to run auto-merge with the
configured options, these options are carried by the Store for now. When we add
a "jj resolve" flag to run auto-merge with different configuration, we might
have to parameterize the options passed in to MergedTree::resolve().
2025-09-09 03:44:16 +00:00
Remo Senekowitsch
51224ed675 cli: deprecate metaedit-functionality of commit and describe
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-08 06:00:35 +00:00
Ilya Grigoriev
93368f114f codespell: forbid British English
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
As suggested by @PhilipMetzger

The word "grey" is whitelisted because
- we have a contributor of that name
- we use a library that uses "Grey" as a member of an enum
- I refuse to believe "grey" is not US English
2025-09-07 15:51:44 +00:00
Scott Taylor
51ad8a0d01 cli: commit: explain that jj describe && jj new is equivalent
Suggested in #7429.
2025-09-07 12:57:08 +00:00
Remo Senekowitsch
97823cafdf cli config: suggest metaedit over describe --reset-author 2025-09-07 10:01:11 +00:00
Yuya Nishihara
3f434adbea formatter: migrate away from .with_label*() functions
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-07 08:17:06 +00:00
Yuya Nishihara
e1d0ec163c formatter: reimplement LabeledWriter as RAII type
This allows us to use the return value of .labeled() as a formatter.
2025-09-07 08:17:06 +00:00
Yuya Nishihara
2c0f65e17d formatter: move labeled() to extension trait, add owned version
It seemed a bit odd that we had to get a trait object to call labeled().

The dyn Formatter fn is removed. I considered adding a forwarding function, but
there aren't many modules where FormatterExt has to be imported.
2025-09-07 08:17:06 +00:00
Yuya Nishihara
6a7999af69 formatter: add forwarding impls for &mut/Boxed Formatter
This will help implement Drop for T: Formatter. The trait bounds required by
Drop should also be listed in the type declaration.
2025-09-07 08:17:06 +00:00
Gaëtan Lehmann
8a1297e6c4 status: fix markdown list rendered on a single line 2025-09-07 07:24:51 +00:00
Benjamin Tan
6a1163472e cli complete: resolve: only complete mutable conflicting revisions
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-06 10:21:06 +00:00
Benjamin Tan
b70a12e2db docs: standardize usage of term "colocate" without the hyphen
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The hyphen-less version is preferred since there are already existing
command flags and config options which use the hyphen-less variation.
2025-09-05 16:32:25 +00:00
Austin Seipp
5b83c9899c cli, lib: convert revset expressions to use Arc over Rc
We want these to be `Send` and `Sync` so we can send them between
threads in our multi-threaded backend. This requires a bunch of subsequent
(but obvious) changes throughout cli and the tests.

Co-authored-by: Benjamin Brittain <ben@ersc.io>
Signed-off-by: Austin Seipp <austin@ersc.io>
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-05 16:09:44 +00:00
Martin von Zweigbergk
ba60fe1c61 revset: require SymbolResolverExtension to be Send and Sync
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This will make `RevsetExtensions` also `Send` and `Sync`, which the
CLI crate already kind of assumes since it stores `RevsetExtensions`
in an `Arc`.
2025-09-05 11:25:22 +00:00
Yuya Nishihara
760ab75c5e formatter: make push/pop_label() never fail
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This will help implement Drop for labeled formatter guard.
2025-09-05 03:40:29 +00:00
Yuya Nishihara
6a70a9bdb9 formatter: emit pending color sequence on flush() instead of pop_label()
formatter.with_label(..) API is getting complicated, and I'm thinking of
replacing .with_label*() functions with .labeled() that will do .pop_label() on
Drop.

This patch means that the last escape sequence is more likely emitted by Drop,
which is less reliable. However, in practice, output payload is terminated by
newline, and therefore, reset sequence would have been emitted by write().
Ignoring io::Error in Drop wouldn't be horrible either since subsequent write()
on the same stream would likely fail.
2025-09-05 03:40:29 +00:00
Yuya Nishihara
4dee8e46ce conflicts: compare new hunks without fully materializing original to text
It seemed odd that we had to pass ConflictMarkerStyle to snapshot functions.
Suppose materialize/parse functions aren't lossy, we can compare hunks in
Vec<Merge<BString>> form. This should also be robust for configuration changes.

test_materialize_parse_roundtrip_different_markers() is simplified as there
should no longer be "pair" of marker styles.
2025-09-05 00:39:41 +00:00
Yuya Nishihara
9f69c58233 cli: help: look up subcommand without using error path
It's odd that cmd_help() returns an error for valid arguments. Let's look up the
target command explicitly. We still need to do app.try_get_matches_from_mut() to
initialize clap::Command internals, though.
2025-09-05 00:26:12 +00:00
Martin von Zweigbergk
da6c4b61b3 backend: remove unused TreeValue::Conflict and read/write methods
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
We no longer use the `TreeValue::Conflict` constructor or the
`Backend::read_conflict()` and `Backend::write_conflict()` methods.
2025-09-04 16:26:44 +00:00