Commit graph

4385 commits

Author SHA1 Message Date
Yuya Nishihara
0dcf73e46b op_store: serialize proto without constructing empty slot
It's easier to detect missed assignments if all fields are listed explicitly.
2025-09-19 00:29:28 +00:00
Yuya Nishihara
e236180a22 op_store: flag legacy git_refs.commit_id field as deprecated 2025-09-19 00:29:28 +00:00
Austin Seipp
7ec5980f26 revset: add new exactly(x, n) expression
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
With `all:` having gone away, some users (including me) had been using it
to enforce an invariant: by omitting it, an expression was guaranteed to
yield exactly one result. For example, this is important when using tools
like `jj rebase -B/-A`

Instead, let's fix that case by building that functionality into the
revset language itself. The previous behavior can now be enforced via
the term `exactly(x, 1)`

In the future, `n` could also be a range.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-18 18:48:12 +00:00
Yuya Nishihara
e357281135 op_store: drop support for legacy remote bookmarks without tracking state
This code was added by 4af678848d "op_store: minimal change to load/store
tracking state of remote branches" (2023-10-16). It's unlikely that the head
operation was written by jj older than that. Remote refs in old views are now
mapped to State::New unconditionally, which should be okay for read-only
operations.
2025-09-16 15:07:34 +00:00
Yuya Nishihara
c344547fad op_store: add error propagation path to view_from_proto() 2025-09-16 15:07:34 +00:00
Yuya Nishihara
3e029758ae tests: rewrite test_fsmonitor() to use TreeState API
This is a test for fsmonitor API integration, in which we wouldn't have to use
the WorkingCopy API with escape hatch.
2025-09-16 01:47:50 +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
Yuya Nishihara
ccd1373f1b working_copy: move SnapshotOptions::empty_for_test() to testutils 2025-09-14 03:55:09 +00:00
Yuya Nishihara
4ea52e1b63 git: remove Default from GitSettings
There weren't non-test callers. It should be better to not duplicate the default
values from the default config files.
2025-09-14 03:55:09 +00:00
Martin von Zweigbergk
8aa9d1d362 cleanup: replace clippy allow() exemptions by expect()
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 way the compiler will tell us to clean them up when they're no
longer needed. Thanks to @imp for the suggestion.
2025-09-13 04:42:02 +00:00
Martin von Zweigbergk
c0dfa2f305 revset engine: remove stale clippy exemptions for missing docs 2025-09-13 04:42:02 +00:00
Yuya Nishihara
cee5ea6935 local_working_copy: remove stale clippy exemption
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
I hope it would no longer be an issue since 885b83b5.
2025-09-13 02:11:44 +00:00
Martin von Zweigbergk
c12ee126b4 tree: move try_resolve_file_conflict() to tree_merge() 2025-09-12 16:11:13 +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
Martin von Zweigbergk
5d93019459 merged_tree: extract merge_tree() to new module
`merged_tree.rs` is getting too big. The code for merging/resolving
trees is quite well separated from `MergedTree`'s core logic of
creating a view of the merged input trees on the fly.
2025-09-12 16:11:13 +00:00
Remo Senekowitsch
ddb3e4a4b1 ci: ignore flaky test on windows
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-11 14:34:44 +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
Yuya Nishihara
949fd2a494 merge: parameterize same-change rule of trivial_merge()
merge_ref_targets() uses SameChange::Accept rule explicitly. Since ref changes
are resolved based on ancestry, it seems good to resolve same-change conflicts
as well.
2025-09-11 13:14:28 +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
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
eb75fc5cf7 files: introduce Cow-like wrapper for merge hunks
We could instead use Merge<Cow<BStr>>, but it seemed inconvenient to convert the
inner type back and forth.
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
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
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
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
0b34bb31a6 tests: add test for unchanged conflict in working copy
This test would fail if we removed comparison of materialized contents from
conflicts::update_from_content().
2025-09-05 00:39:41 +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
Martin von Zweigbergk
ea2b53b4ca git_backend: drop support for reading conflicts
We haven't written legacy/path-level conflicts since jj 0.11 (Nov
2023). This patch makes the Git backend return legacy conflicts as the
regular JSON-containing files they are represented by.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
5f3269db2b git_backend: drop support for writing TreeValue::Conflict
We haven't had any code that produces these values in a long time.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
5f7f4318a0 working_copy: drop support for legacy trees
Legacy trees (those with conflicts recorded at the path level) have
not been created since 0.11 (Nov 2023). We're about to deprecate them
now. This patch removes support for them in the working copy. If
anyone still has a commit checked out at a legacy tree, we will now
interpret that as a modern tree, meaning that any conflicts will
appear as regular files with JSON contents in the previous snapshot,
so if we re-snapshot the working copy (and e.g. the mtime has
changed), these files will become resolved with the conflicts markers
still in them.

I think it's quite unlikely that anyone has working copies this old so
I didn't mention it in the changelog.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
d0913449d0 simple_store: drop support for legacy trees
Users should not be using the simple backend for anything serious, and
they definitely should not have any repos from back when we used
legacy trees.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
720b8cc114 bisect: add library for running bisection
I plan to add a `jj bisect run --range REVSET --command COMMAND` that
uses this library.
2025-09-04 14:30:52 +00:00
Remo Senekowitsch
ec5c135387 git: colocate repos by default
Closes https://github.com/jj-vcs/jj/issues/7189

Colocated repos have some advantages and some disadvantages. On the
whole, I think making Git repos colocated by default is a better
trade-off, especially for new users. With the `git.colocate` setting,
(experienced) users can easily change this according to preference.

A non-exhaustive list of pros and cons of colocated repos:

pros:
* Many code editors show the changes one is currently working on based
  on Git's "dirty worktree".
* There are a lot of tools that integrate with Git which don't work at
  all in non-colocated repositories.
* There are a lot of Git features that Jujutsu doesn't have yet. When
  users ask for them, the answer is usually: "Just colocate your repo
  and run git directly for now." It's a strength that Jujutsu can focus
  on what makes it special and not have to rush the reimplementation of
  every niche feature of Git. Examples: `git rebase` tracking file
  renames, `git bisect`, `git tag`, `git range-diff`, submodules.

cons:
* Jujutsu performs worse in colocated repositories with lots of refs,
  because of the automatic `jj git import`.
* Colocated repos make branch@git references show up in Jujutsu output,
  which is usually just aesthetically displeasing or possibly even
  confusing to inexperienced users.
* Interleaving jj and (mutating) git commands can lead to confusing
  situations. Examples:
  * Creating a commit with git instead of jj will often leave a
    duplicate "work in progress" commit in Jujutsu's log.
  * Some IDEs periodically run `git fetch` in the background. This can
    lead to conflicted branches and divergent change IDs, something many
    people struggle with.
2025-09-04 11:26:28 +00:00
Ian Wrzesinski
ee6ae0662a working_copy: Add WorkingCopyStateError conversions for ergonomics
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
Note that the actual error message is almost always the same. They all end up
with the message "Failed to read working copy state" in `tree_state`. So the
original code adding another equivalent message is unnecessary.
2025-09-03 13:19:12 +00:00
Yuya Nishihara
1cd6f9f6a8 conflicts: pack marker style/len into struct, merge materialize functions
I'm thinking of adding an option to do word-by-word merging, which will be pass
down to files::merge_hunks() through materialize_merge_result*(). Since tree
merging should also respect this option, it will be carried by the Store, and
copied to ConflictMaterializeOptions.
2025-09-03 09:34:44 +00:00
Martin von Zweigbergk
c6e4711928 working_copy: mark unused conflict_id proto field reserved
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 field has been unused since it was deprecated in 97b81a0f (~2
years ago). It should have been marked reserved instead of deprecated
already then.
2025-09-03 05:47:08 +00:00
Ian Wrzesinski
f3d41b1826 working_copy: Move conlfict_marker_styles to TreeState 2025-09-03 00:40:52 +00:00
Ian Wrzesinski
f882681dd8 working_copy: Simplify Eol loading in TreeState init functions 2025-09-03 00:40:52 +00:00
Jade Lovelace
735a27d4ef templates: add string.match function
This allows for any matcher type and allows extracting a capture group
by number.
2025-09-02 02:19:54 +00:00
Yuya Nishihara
b5c5a442e5 working_copy: set MaterializedConflictData by caller of write_conflict()
Since file stats and conflict metadata are calculated from different sources,
it's simpler to initialize FileState without MaterializedConflictData.
2025-09-02 00:52:13 +00:00
Yuya Nishihara
3654b8ba19 working_copy: pass slice to write_conflict(), rename variables
It seemed confusing that we had "conflict_data" as file content, and
MaterializedConflictData as metadata.
2025-09-02 00:52:13 +00:00
Josh Steadmon
f5e77069f3 merge: fix formatting in Merge method doc comments
Rustdoc was losing the formatting of the merge diagrams in
`Merge::flatten()`'s doc comment; preserve it with an HTML `<pre>`
block.

Also remove a stray backtick that broke formatting in
`Merge::to_file_merge()`'s doc comment.
2025-08-29 17:43:01 +00:00
Remo Senekowitsch
5947632027 config: use schema directive comment
Tombi is an LSP that complains about the "$schema" key, because it
itself is not actually part of our schema. Taplo is another LSP that
can read this comment directive. Using a comment seems generally more
appropriate. Syntax highlighting makes comments usually less visible,
indicating that the directive is not actually part of the configuration
data.
2025-08-29 14:52:30 +00:00
Yuya Nishihara
42f645ed28 file_util: insert fdatasync() before persisting temporary files
This implements the steps 3-4 described in "When Should You Fsync?"
https://lwn.net/Articles/457667/

With my testing on Linux VM, persisted op_store file names (or directory entry)
can occasionally lost as well as op_heads entries. We can insert fsync(dir_fd)
to fix these, but then we'll get data corruption somewhere in Git object store.
Since Git/gix writes small files more frequently, I don't think we can easily
address the problem at gix side. I think the current state is not that bad as we
can recover from corruption relatively easily if the op_store contents are
valid.

I had this patch for months, and I didn't find any significant performance
degradation.

#4423
2025-08-29 01:30:43 +00:00
Yuya Nishihara
12f0551842 file_util: add thin wrapper over NamedTempFile::persist()
I'll insert fdatasync() there.
2025-08-29 01:30:43 +00:00
Yuya Nishihara
27ef6359bc working_copy: load checkout state eagerly to fix error propagation
The checkout state should be small, so loading cost wouldn't matter much
compared to the tree state.
2025-08-27 00:58:24 +00:00