Commit graph

3719 commits

Author SHA1 Message Date
Austin Seipp
643c41bc4a lib: allow exactly() to take interval ranges as an argument
It turns out that the use case I had for `exactly()` was slightly more
subtle, and I need range support. In particular, usage of `exactly()`
in expressions used by `revsets.log-graph-prioritize` can and will
cause `jj log` to fail if the assertion fails; in my case, a particular
expression I use should be equal to zero-or-one revisions.

This (ab)uses string literal syntax to parse out a range that is like
a subset of Rust's range syntax; in particular unbounded endpoints like
`x..` or `..=y` are not supported. Ideally the grammar would be expanded
to handle this case more smoothly.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-24 23:17:57 -05:00
Yuya Nishihara
120d492d4e git, op_store: migrate and import "refs/tags/*" as @git remote tags
The migration logic is basically the same as 717d0d3d6d "git: on
deserialize/import/export, copy refs/heads/* to remote named git." Now
git::import_refs() processes bookmarks and tags in the same way.
git::export_refs() is unchanged because we don't have any commands that would
move local tags internally.
2025-09-24 09:09:52 +00:00
Yuya Nishihara
a89680d34b op_store: add remote tags storage and basic accessors
Git-tracking tags will be stored there. I don't have a concrete plan for proper
remote tags support, but I think tags fetched/pushed internally can be recorded
as remote tags.
2025-09-24 09:09:52 +00:00
Yuya Nishihara
0dc1beba12 op_store: make local/remote refs helper generic over RemoteView fields 2025-09-24 09:09:52 +00:00
Yuya Nishihara
aac63636cb op_store: reorganize proto reflecting new RemoteView structure
I'm thinking of adding remote tags table to support tag mutation commands, so I
think it's time to update the storage format. RefTarget is serialized to a list
of alternate terms because we don't need to support legacy formats here.
2025-09-24 09:09:52 +00:00
Ilya Grigoriev
09dea71a15 git-backend: test and make public change id reading from headers
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
Having tests illustrates the behavior. Making this public de-duplicates
the code with ERSC. This also allows determining whether a change id
comes from the header or is synthetic.

This is just a nice-to-have for me, we will also duplicate the code
until this is merged (if that happens).
2025-09-23 03:47:15 +00:00
Ilya Grigoriev
cefc0db81b git_subprocess: make sure we do not try to fetch submodules regardless of .gitconfig
This fixes the bug described below.

I have `submodule.recurse=true` set in my .gitconfig. When trying
to fetch repos with submodules (e.g. git/git), I got errors like these:

```console
$ jj git fetch
remote: Enumerating objects: 853, done.
remote: Total 853 (delta 448), reused 439 (delta 413), pack-reused 315 (from 2)
Error: Git process failed: External git program failed:
Could not access submodule 'sha1collisiondetection'
```

This error occured when fetching only, *not* when cloning. It occured
even when there wasn't anything to fetch.

I only tested repositories that never had submodules initialized or
fetched (which would have to be done with Git).
2025-09-22 20:50:50 +00:00
Yuya Nishihara
9a5e2ae02e op_store: remove stale TODO about renamed remote and view state
We aren't going to fix this problem by inserting another indirection, at least
to the view layer.
2025-09-22 00:08:45 +00:00
Martin von Zweigbergk
4f456ec824 merge: add a generic Diff<T> type, use in TreeDiffEntry
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 think this helps readability a bit. I updated `TreeDiffEntry` and a
few related places. I think there are many other places where we could
use the new type.
2025-09-21 16:16:33 +00:00
Martin von Zweigbergk
452a1a454c cli_util: rename Diff to ContentDiff
I'm about to add a generic `Diff<T>` that's more similar to
`Merge<T>`, so I want to free up the name. It seems better to have
`Diff<T>` and `ContentDiff` than e.g. `GenericDiff<T>` and `Diff` or
having to use qualified imports.
2025-09-21 16:16:33 +00:00
Yuya Nishihara
1d80c19aea revset: leverage trait upcasting in InternalRevset 2025-09-20 01:22:47 +00:00
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
bd2807fdbc store: downcast to implementation type by backend_impl()
It should be safer to restrict the type here.
2025-09-20 01:22:47 +00:00
Yuya Nishihara
819065000e cleanup: use .as_chunks() instead of chunks_exact() 2025-09-19 09:41:32 +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
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
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
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