Commit graph

4209 commits

Author SHA1 Message Date
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
Yuya Nishihara
a2a5ccf772 working_copy: propagate I/O-related errors 2025-08-27 00:58:24 +00:00
Yuya Nishihara
2d8ca26f15 working_copy: leverage CheckoutState::save() to create initial state file
With this patch, init() would no longer panic when the checkout state already
existed. This should be okay because the caller always create new workspace
directory.
2025-08-27 00:58:24 +00:00
Christian Hufnagel
75f8a0e730 cli touch: add flag for changing author date 2025-08-26 19:02:31 +00:00
Ian Wrzesinski
9d67c47a0c working_copy: Break out CheckoutState load and save functions 2025-08-25 22:40:48 +00:00
Ivan Petkov
72fde508c6 lib: support negative refspecs on git remotes 2025-08-25 15:55:18 +00:00
Ivan Petkov
98ce815699 lib: add representation for a negative git refspec 2025-08-25 15:55:18 +00:00
Ivan Petkov
27d4c80c50 lib: require caller to provide an expanded list of refspecs to fetch 2025-08-25 15:55:18 +00:00
Ivan Petkov
e0ca7c653d lib: refactor git fetch ahead of future updates 2025-08-25 15:55:18 +00:00
Ian Wrzesinski
5f8dd79e8b working_copy: Move TreeState struct definition closer to impl block 2025-08-25 07:01:09 +00:00
Graham Christensen
1b150d12bd test: use a fifo in test_local_working_copy to avoid too-long unix domain sockets on macOS 2025-08-23 13:48:25 +00:00
Graham Christensen
297c434c93 ci: Skip the GPG tests if they cannot pass on macOS 2025-08-23 13:48:25 +00:00
Yuya Nishihara
1b33da4df2 config: remove workaround for implicit inline table insertion
This reverts commit 31d12c9245. The problem should
be fixed by upstream:

> Implicitly treat Tables inside of a Value as an InlineTable, rather than
> skipping them
https://github.com/toml-rs/toml/blob/main/crates/toml_edit/CHANGELOG.md#0230---2025-07-08
2025-08-23 03:46:11 +00:00
Yuya Nishihara
7e80eb4dfa cargo: bump toml_edit to 0.23.3
Also updated deprecated ImDocument references to Document.
2025-08-23 03:46:11 +00:00
Yuya Nishihara
cd673311d0 index: remove forwarding function of CompositeIndex::evaluate_revset()
Since Index is now implemented for CompositeIndex instead of &CompositeIndex,
these two functions have exactly the same signature. We no longer need a
specialized implementation to correct lifetime of the return value.
2025-08-22 00:29:32 +00:00
Yuya Nishihara
425b719045 templater: add CommitEvolutionEntry type
I don't have a strong feeling whether we should add "entry.commit() -> Commit"
method or forward method calls to the Commit object, but this patch implements
the former because:

 a. evolution_entry.diff() should return inter diff, whereas commit.diff()
    doesn't.
 b. auto-labeling works if self.commit() is an explicit method call.
 c. the implementation and documentation can be simple.

Tests will be added by the next patch.
2025-08-21 13:35:21 +00:00
Yuya Nishihara
fe7013b3dc commit: make is_empty() and parent_tree() query index first
This makes "jj log" in merge-heavy repos fast.
2025-08-21 09:38:38 +00:00
Yuya Nishihara
631bf709ec index: add generic interface to query changed paths in commit
Commit::is_empty() and ::parent_tree() will query index first to avoid merging
parent trees.

iirc, the Google backend has an index of changed paths, so I made the added
function return Result although the default index will never fail. I also
considered adding matcher argument, but I don't have any use case right now. I
think the Matcher API would be too abstract to construct a database query. Maybe
we should use Revset/FilesetExpression types for that purpose.
2025-08-21 09:38:38 +00:00
George Christou
7562064739 fileset: simplify glob character detection 2025-08-21 09:29:08 +00:00
Martin von Zweigbergk
2e8d23739d rewrite: make merge_commit_trees_no_resolve_without_repo() non-recursive
We ran into the following error when upgrading to the latest unstable
rustc at Google when compiling our internal commit backend:

```
overflow evaluating the requirement `impl futures::Future<Output = Result<jj_lib::tree::Tree, jj_lib::backend::BackendError>>: Sized`
```

It seems to be some limitation of rustc related to recursion and async
functions but we don't know what exactly it means.

This patch works around that by making the async part of
`merge_commit_trees_no_resolve_without_repo()` non-recursive. There is
still a recursive part, but it's no longer async. The recursive part
now finds all the commit IDs involved. Then we do the lookup of them
afterwards.

We may want to make the remaining recursive part non-recursive as well
so don't run out of stack on a long braid of criss-cross merges, but
that can come later.
2025-08-20 13:58:10 +00:00
Martin von Zweigbergk
353be90e3d rewrite: add test of recursive criss-cross merge resolution
We didn't seem to have a test case of the recursive merge
implementation (no tests failed when I changed it to always use the
first ancestor instead of being recursive).
2025-08-20 13:58:10 +00:00
George Christou
44ab63867d fileset: add case-insensitive glob patterns
Add support for case-insensitive glob patterns in filesets, similar to the
existing glob-i: patterns in revsets.

Resolves #5945
2025-08-20 10:51:51 +00:00
Ian Wrzesinski
2768441d80 working_copy: Factor out new_state function
This constructor is just large enough to be worth extracting.
2025-08-18 10:52:12 +00:00
Ivan Petkov
1df3c5d3b7 lib/git: support temporarily fetching all tags as part of a fetch
By default `git clone` will fetch all tags on a remote (unless
`--no-tags` is specified). Eventually we'll want to support the same
behavior, though since we first configure a remote and then fetch, we'll
need to configure the remote with the correct *general* tag fetching
behavior, but still perform the first fetch with all tags included.
2025-08-17 15:48:36 +00:00
Remo Senekowitsch
36ee36ce78 op: undo: rename to revert
This paves the way for the semantics of `jj undo` and `jj op revert` to
evolve independently. `jj op revert` is going to stay the low-level
command to apply the inverse of any operation. The new name is
consistent with `jj revert`, which applies the inverse of a commit.

`jj undo` on the other hand is planned to become a higher-level command,
which is more similar to, say, Ctrl+Z in typical GUI applications.
Running `jj undo` repeatedly will revert progressively older operations,
allowing the user to walk backwards in time. At the same time, `jj undo`
will lose the abilitly to revert arbitrary operations, to keep its
semantics simple and intuitive.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-15 21:31:15 +00:00
Yuya Nishihara
2391764ab7 revset: integrate change-path index
The current implementation does linear search, which I think is good assuming
the size of the changed paths set is usually small. The next costly part of "jj
log PATH" is commit.empty() template on merge commits (#5411). We'll need a
public API to query changed-path index to optimize it.
2025-08-15 11:46:49 +00:00
Yuya Nishihara
8999e08d2e index: add function to build changed-path index at certain operation 2025-08-15 11:46:49 +00:00