Skip to content

Conversation

@bts
Copy link
Contributor

@bts bts commented Oct 26, 2025

This is the last in 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.

Previous PRs in this line of work: #7799, #7823, #7830, #7832, #7843.

A few things to note:

  • Introduced a few more instances of the existing anti-pattern, TODO: indexing error shouldn't be a "BackendError". Filed issue Task: Improve error handling where IndexErrors are wrapped in BackendError #7849 to track this.
  • 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).

This closes #7825.

Thanks to Martin, Yuya, and Philip for guidance with these fallibility changes! I appreciate your help.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@bts bts requested a review from a team as a code owner October 26, 2025 02:54
@martinvonz
Copy link
Member

I think most of the PR description is talking about one of the two commits. Could you move those parts to the commit message of the relevant commit?

@bts bts force-pushed the bts/fallible-ancestors branch 2 times, most recently from 78df233 to d63bdea Compare October 26, 2025 13:18
@bts
Copy link
Contributor Author

bts commented Oct 26, 2025

@martinvonz Just added the additional respective details from the PR description to each of the commit messages.

@bts bts force-pushed the bts/fallible-ancestors branch from d63bdea to 8a5e760 Compare October 27, 2025 15:06
@bts bts requested a review from yuja October 27, 2025 15:10
@bts bts force-pushed the bts/fallible-ancestors branch from 8a5e760 to 3c65d54 Compare October 27, 2025 15:22
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

bts added 2 commits October 28, 2025 09:11
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 jj-vcs#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 jj-vcs#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).
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 jj-vcs#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 jj-vcs#7849.

Closes jj-vcs#7825.
@bts bts force-pushed the bts/fallible-ancestors branch from 3c65d54 to 0b4e456 Compare October 28, 2025 13:21
@bts bts added this pull request to the merge queue Oct 28, 2025
Merged via the queue into jj-vcs:main with commit 8fcb46e Oct 28, 2025
29 checks passed
@bts bts deleted the bts/fallible-ancestors branch October 28, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Support distributed implementations of index traits

3 participants