Commit graph

4311 commits

Author SHA1 Message Date
Ilya Grigoriev
7d81b9164a testutils: add git feature, make gix dependency optional
This makes it possible to use `testutils` without depending on all of
`gix`.

Users of testutils without the Git feature would currently either have
to use the LocalBackend or provide their own replacement to `TestRepo`.

`jj-lib`'s test still depend on Git. Both before and after this PR,
`cargo test --no-build -p jj-lib --no-default-features` fails to
compile. This seems like a difficult problem to address; this PR merely
tries to not make the situation worse.

**Motivation**: In at least one ERSC use-case, we'd like to use `testutils`, but
the gix dependency makes tests crash with the following error:

```
[test]     thread 'gitoxide.in_parallel.produce.0' panicked at code/...:
[test]     there is no reactor running, must be called from the context of a Tokio 1.x runtime
```

It's not clear to me why this happens (@davidbarsky claims to have an
idea), but this PR seems like a good workaround that also decreases the
amount of things we'd need to compile.
2025-10-28 10:55:35 -07:00
Brian Schroeder
8fcb46e56a index: make Index::common_ancestors fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.

This introduces another instance of the existing anti-pattern, `TODO:
indexing error shouldn't be a "BackendError"`. We're tracking this known
issue in #7849.

Closes #7825.
2025-10-28 13:47:44 +00:00
Brian Schroeder
7810926c35 index: make Index::is_ancestor fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.

- Introduced a few more instances of the existing anti-pattern, `TODO:
  indexing error shouldn't be a "BackendError"`. We're tracking this
  known issue in #7849.
- Converted `MutableRepo::merge_view` to return a `RepoLoaderError`
  instead of a `BackendError`. The only caller, `MutableRepo::merge`,
  already returns a `RepoLoaderError`.
- Added three "`fallible_`" iterator helpers to reduce the amount of
  noise at `is_ancestor` call sites due to the method now being
  fallible. Using these helpers seem to produce code that's a little
  more readable than using `process_results` from itertools. One
  consideration in this trade-off is that these helpers do not
  themselves return iterators: if we find that we need more support for
  fallible combinators mid-"chain" of iterator combinators, we might
  either want to use `process_results` only in those cases, or switch to
  use of `process_results` across the board (in lieu of these new
  helpers).
2025-10-28 13:47:44 +00:00
Scott Taylor
a16c89f16e conflicts: render exactly one snapshot in "diff" marker style
Although rare, it would be very confusing to a user if they encountered
a conflict with a `-------` marker while using the "diff" style. This
addresses a TODO in the test.
2025-10-28 12:43:08 +00:00
Ilya Grigoriev
5fc339abf5 debugging: comment on why impl Debug for jj_lib::Commit is not informative 2025-10-28 03:10:52 +00:00
Martin von Zweigbergk
9d81ad4ae3 cleanup: remove some unnecessary anonymous lifetime annotations
This change was motived by the next Gitoxide version adding an
additional lifetime to `gix::reference::iter::Iter`, which currently
breaks the automated Dependabot upgrade.

I left annonymous lifetime annotations on ref-like types like
`RemoteRefSymbol`.
2025-10-28 03:05:32 +00:00
Martin von Zweigbergk
7724f52d71 git_backend: reduce duplication of basename handling 2025-10-27 18:36:57 +00:00
Martin von Zweigbergk
a11c5eb4e4 predecessors: add option to not include them in commits
We want to eventually stop writing predecessors in the commit object
since we now have them in the operation object. That will expose some
problems with creating cycles between commits. This patch adds a
config option for not recording predecessors in commits so we can
start testing and fixing those issues.
2025-10-27 16:35:47 +00:00
Yuya Nishihara
ffdd6025ad dag_walk: avoid using unwrap() to strip off infallible error
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're now allowed to omit Err(_) if it can never be constructed.
2025-10-27 15:17:34 +00:00
Martin von Zweigbergk
b62438e398 repo: propagate error when there's a cycle in parent_mapping
We were sometimes seeing crashes at Google when a commit was rewritten
very quickly without any changes. This should prevent the crashes and
return an error to the user instead.
2025-10-27 14:16:34 +00:00
Martin von Zweigbergk
d8acbec3fc dag_walk: propagate error when cycle is detected
A sibling team of my team sometimes runs into panics caused by cycles
in the commit graph. This patch removes the panics from `dag_walk` by
having all the callers pass in a `cycle_fn`. For now, the callers
panic instead.
2025-10-27 14:16:34 +00:00
Brian Schroeder
b8fa9ecf9c index: make Index::has_id fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.
2025-10-25 18:05:13 +00:00
Yuya Nishihara
5f40f62494 cleanup: remove redundant + use<'_> after migrating to 2024 edition
AliasFunctionOverloads::arities() doesn't need to capture &self, but it's not
important to describe the lifetime precisely here.
2025-10-25 02:09:31 +00:00
Brian Schroeder
159fb829d5 index: make Index::resolve_commit_id_prefix fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.
2025-10-24 10:51:56 +00:00
Brian Schroeder
385fb064b9 index: make Index::shortest_unique_commit_id_prefix_len fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.
2025-10-24 10:51:56 +00:00
Lander Brandt
61691755fe lib: optimize file handle usage when calling into same_file during
checkout

See https://github.com/jj-vcs/jj/pull/7695 for motivation/background

One of the hottest paths in `jj` during checkout is `can_create_file`
and `create_parent_dirs`. Both of these functions check to ensure that
there aren't attempts to write to special directories
(`reject_reserved_existing`) which is a fairly expensive check.

This change reduces file open/close syscalls by reusing file handles
when possible.
2025-10-24 00:42:00 +00:00
Brian Schroeder
37da011be8 index: make MutableRepo::merge_in fallible
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 is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.
2025-10-23 20:52:16 +00:00
Brian Schroeder
c70f9b5b3f index: make ChangeIdIndex::shortest_unique_prefix_len fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which can produce I/O errors during operation. See #7825 for more
information.
2025-10-23 15:28:33 +00:00
Brian Schroeder
5468bb49d3 index: make ChangeIdIndex::resolve_prefix fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which can produce I/O errors during operation. See #7825 for more
information.
2025-10-23 15:28:33 +00:00
Brian Schroeder
2d1acbec3b index: add IndexStoreResult type alias over IndexStoreError results
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
By introducing `IndexStoreResult`, we follow the pattern used by other
storage traits: `BackendResult`, `OpStoreResult`, and `IndexResult`.
2025-10-23 02:07:08 +00:00
Brian Schroeder
fc1639b1e1 index: add IndexResult type alias over IndexError results
By using a type alias, we match how `Backend` and `OpStore` traits
organize their errors. This will be useful as we progressively convert
more methods on `Index`, `MutableIndex`, `ReadonlyIndex`, and
`ChangeIdIndex` traits to return `Result<T, IndexError>` in order to
support networked implementations which can produce I/O failures.
2025-10-23 02:07:08 +00:00
Brian Schroeder
378e80cfff index: unify IndexStore errors into IndexStoreError enum
This way we match how the errors are organized for other storage traits.
2025-10-23 02:07:08 +00:00
Brian Schroeder
551e600405 index: unify Index errors into IndexError enum
This way we match how errors are organized for the other storage traits,
and we allow for networked implementations of `Index::all_heads_for_gc`
to return I/O errors.
2025-10-23 02:07:08 +00:00
Ilya Grigoriev
ca2b478a76 clippy: nightly clippy fixes (more Self)
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-10-21 02:00:14 +00:00
Martin von Zweigbergk
d39962416d revset: try to clarify error from exactly()
The error is currently something like "The revset was expected to have
1 elements, but more were provided". It wasn't at first clear what
"provided" was referring to. Of course it can only really refer to the
revset, but I think we say it more clearly as "The revset has more
than the expected 1 revisions". Note that I also changed "elements" to
"revisions" to clarify that the elements are revisions.
2025-10-20 22:56:32 +00:00
Martin von Zweigbergk
6fd96a75eb revset: "less [elements] were provided" -> "fewer were provided"
"Elements" is countable, so I think it should be "fewer".
2025-10-20 22:56:32 +00:00
Austin Seipp
b151a08c3b cargo: update to prost 0.14.1
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 requires regenerating the proto files, which now derive Eq and
Hash automatically.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-10-20 19:52:18 +00:00
Martin von Zweigbergk
3a511becd6 cargo: bump ignore crate to 0.4.24
This includes the fix for
https://github.com/BurntSushi/ripgrep/issues/3127. The fix let us
optionally allow unclosed character classes in .gitignore files. It is
allowed by default when using the `GitignoreBuilder` (as we do), so we
get the fix without code changes.
2025-10-20 17:20:14 +00:00
Scott Taylor
cbfceb631c merged_tree: rename take() to into_merge()
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 is consistent with `MergedTreeId::into_merge`.
2025-10-19 13:14:27 +00:00
Scott Taylor
141832414a backend: remove MergedTreeId::Legacy variant
I'm planning to try to add conflict labels to `MergedTree` and
`MergedTreeId`, and it will be easier to add them if both are structs
with similar methods. Since we don't support reading/writing legacy
conflicts anymore (as far as I'm aware), I think it should be safe to
delete the `MergedTreeId::Legacy` variant now.
2025-10-19 13:14:27 +00:00
Benjamin Brittain
730d633c73 op_heads_store: convert OpHeadsStore trait to be async
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 is primarily for consistency with the other storage traits.
2025-10-19 05:58:09 +00:00
Benjamin Brittain
3881bd52d7 op_store: convert OpStore trait to be async
This is primarily for consistency with the other storage traits.
2025-10-19 05:46:00 +00:00
Owen Brooks
f88b0d8093 cli: git clone: add --branch option
When cloning with the branch option:
- Only the specified branch will be fetched
- The trunk alias is only set if the specified branch happens to be the default branch
- The clone fails if the branch does not exist in the remote
2025-10-19 05:14:11 +00:00
Owen Brooks
e98e2e58c8 cli: Add RefExpansionError for expand_fetch_refspecs 2025-10-19 05:14:11 +00:00
Martin von Zweigbergk
e6d23b60dd git_backend: correct comment about reading conflict data from extra table
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 comment currently says that we update all conflicted commits when
reading the derialized extra metadata, but that's not true for commits
with the `jj:trees` commit header.
2025-10-19 02:57:17 +00:00
Yuya Nishihara
e555f863a8 fileset, revset: do not omit parentheses from expression span
If parentheses were omitted, a prefix/postfix expression span reconstructed from
sub expressions would become invalid.

Fixes #7747
2025-10-18 02:45:42 +00:00
Yuya Nishihara
bd98243071 revset: extract test for function call parsing
I'll add a helper function that would be useful only for the function call
tests.
2025-10-18 02:45:42 +00:00
Yuya Nishihara
9f75ee6110 revset: use Pair type consistently when passing parsed tree around 2025-10-18 02:45:42 +00:00
Yuya Nishihara
0fb99c12cc templater: include remote tags in "tags" output
Since we can now update tags internally, local and remote tags may be out of
sync in non-colocated Git repositories. "tags" template should indicate that.
2025-10-16 15:44:50 +00:00
Martin von Zweigbergk
beda1381bd working_copy: make potentially slow methods async
There's no pressing need, but we should do this eventually.
2025-10-15 03:27:06 +00:00
Yuya Nishihara
937d88ff25 cli: bookmark: allow tracking/untracking absent remote bookmarks
#7072
2025-10-15 01:52:19 +00:00
Yuya Nishihara
82dd14fd85 git: ensure RemoteView is created for remote with no existing refs
This will help "jj bookmark track" know whether absent remote ref can be created
for the specified remote. "jj bookmark" subcommands shouldn't depend on
gix::Repository API.
2025-10-15 01:52:19 +00:00
Yuya Nishihara
429fec1ae3 git: export tag changes
Although we don't have "jj git tag set"/"delete" commands, this fixes weird undo
behavior #6325. The discussion in #6325 is derailed, but there would be another
issue for the "abandon unreachable" behavior.

Fixes #6325
2025-10-15 01:31:16 +00:00
Yuya Nishihara
1db9c2def7 git: extract per-ref-type functions that compare and export refs 2025-10-15 01:31:16 +00:00
Yuya Nishihara
2ebc496ca9 git: extract per-ref-type struct from RefsToExport
We'll add tags support.
2025-10-15 01:31:16 +00:00
ase
f34dbabd47 config: add support for --when.workspaces
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-10-14 17:50:07 +00:00
Martin von Zweigbergk
3a7babe4d9 commit: introduce parent_tree_async(), use in already async callers
I haven't checked if this would make any difference anywhere. It's
nice if we can avoid blocking calls in existing async scopes.
2025-10-12 23:26:29 +00:00
bipul
72bfc1c96f config: add workspace-level configuration support
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
- Added support for workspace-specific configuration using `jj config` commands.
- Introduced `--workspace` option to `jj config edit`, `jj config set`, and `jj config unset`.
- Workspace configuration file is stored in `.jj/workspace-config.toml` per workspace.
- Simplified workspace path handling logic.
- Updated documentation and test snapshots to reflect new behavior.

This improves flexibility for users working across multiple workspaces.

Co-authored-by: Eidolon <furyhunter600@gmail.com>
Co-authored-by: ase <adam@sandbergericsson.se>
2025-10-12 14:43:12 +00:00
Yuya Nishihara
26bbda9d73 git: on import, do not ignore absent tracked remote refs
Since "tracked" state doesn't exist in Git, git::import_refs() should ignore
absent->absent "changes". git::export_refs() just works because it compares only
ref targets.
2025-10-11 11:59:28 +00:00
Yuya Nishihara
081f35d986 view: allow setting tracked state to absent remote refs
This will allow us to set up tracking state and push new bookmarks in two steps
#7072.

Absent tracked remote refs are deleted with the corresponding local ref. I
originally considered this rule could be enforced by git::import/export_refs(),
but it seemed weird if absent remote refs were left when the tracking local ref
was deleted by user. Therefore, this invariant is ensured by the view API.

Since "jj bookmark track" cannot track absent remote refs yet, this patch
doesn't have UX changes that should be documented.
2025-10-11 11:59:28 +00:00