Skip to content

[API] Abstract over repository roots to simplify the addition of new repository formats - #6680

Merged
rjbou merged 2 commits into
ocaml:masterfrom
kit-ty-kate:abstract-repository-root
May 22, 2026
Merged

[API] Abstract over repository roots to simplify the addition of new repository formats#6680
rjbou merged 2 commits into
ocaml:masterfrom
kit-ty-kate:abstract-repository-root

Conversation

@kit-ty-kate

@kit-ty-kate kit-ty-kate commented Sep 9, 2025

Copy link
Copy Markdown
Member

Extracted from #6625
Queued on #6679
To be merged at the same time as ocaml-opam/opam-rt#86

As mentioned in #6625, adding abstract types over repository roots allows us to simplify and ensure correctness when adding a new format of repository.

In its current form, this PR also changes a couple of unrelated thing that i failed to change back when extracting from #6625 (removal of some use and logic associated with OpamRepositoryConfig.repo_tarring) so it needs at least a cleanup before it is in a mergable state (on top of being queued on the already substantial #6679)

@kit-ty-kate kit-ty-kate added this to the 2.5.0~alpha1 milestone Sep 9, 2025
@kit-ty-kate kit-ty-kate added PR: WIP Not for merge at this stage PRIORITY AREA: API PR: QUEUED Pending pull request, waiting for other work to be merged or closed labels Sep 9, 2025
Comment thread src/client/opamCommands.ml Outdated
Comment thread src/state/opamUpdate.ml Outdated
Comment on lines +21 to +23
let safe_read_repo_file = function
| OpamRepositoryRoot.Dir dir ->
OpamFile.Repo.safe_read (OpamRepositoryPath.repo dir)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

better have this function is OpamRepositoryState (cf related comment in 6625)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used the already existing OpamRepositoryRoot.delayed_read_repo function instead

Comment thread src/state/opamUpdate.ml Outdated
@rjbou

rjbou commented Oct 9, 2025

Copy link
Copy Markdown
Collaborator

I've pushed some commits that contains some reviews proposals, left some comments. It is a very preliminary review comments, i still have some blind spot (that's why i refer to 6625 comments too).

@rjbou
rjbou force-pushed the abstract-repository-root branch from 283ee7a to 17fd765 Compare October 10, 2025 17:28
@kit-ty-kate
kit-ty-kate force-pushed the abstract-repository-root branch from 17fd765 to baf0725 Compare October 10, 2025 22:33
@kit-ty-kate
kit-ty-kate marked this pull request as ready for review October 11, 2025 00:04
@kit-ty-kate kit-ty-kate removed PR: QUEUED Pending pull request, waiting for other work to be merged or closed PR: WIP Not for merge at this stage labels Oct 11, 2025
kit-ty-kate added a commit to kit-ty-kate/opam-rt that referenced this pull request Oct 11, 2025
@kit-ty-kate
kit-ty-kate requested a review from rjbou October 11, 2025 22:10
Comment thread src/client/opamCommands.ml Outdated
Comment thread src/state/opamUpdate.ml
Comment thread src/repository/opamRepositoryRoot.ml
Comment thread src/repository/opamRepositoryRoot.mli
Comment thread src/repository/opamRepositoryRoot.mli
Comment thread src/client/opamArg.ml
@rjbou
rjbou force-pushed the abstract-repository-root branch from 76b1706 to 3a80890 Compare April 29, 2026 17:21
@rjbou
rjbou marked this pull request as draft April 29, 2026 17:22
@rjbou
rjbou force-pushed the abstract-repository-root branch from 3a80890 to af4a114 Compare April 30, 2026 18:26
@rjbou
rjbou marked this pull request as ready for review May 12, 2026 17:12
@rjbou
rjbou force-pushed the abstract-repository-root branch from af4a114 to 2857336 Compare May 12, 2026 17:16
@rjbou

rjbou commented May 12, 2026

Copy link
Copy Markdown
Collaborator

I've update the PR. The last commit is here as a proposal, introduce in the new OpamRepositoryRoot the path construction, like that OpamRepositoryRoot.x.Path module gives directly the well constructed path (e.g. absolute for dirs, partial for tar). The purpose is to not have to handle when we call the finction to construct a path if in that case we need an absolute path or a partial one (ftm, there is only theses 2 cases).
This is not strictly needed by #6625, but imo it helps writing the code.

@kit-ty-kate
kit-ty-kate force-pushed the abstract-repository-root branch from 2857336 to d980844 Compare May 12, 2026 23:24
Comment thread src/client/opamAdminRepoUpgrade.ml Outdated
(OpamRepositoryRoot.Dir.Path.repo tmp_mirror_dir) repo_20;
let dir20 =
OpamRepositoryRoot.Dir.of_dir
OpamRepositoryRoot.Dir.Op.(repo_root / upgradeto_version_string)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this change seems like a separate fix rather than a change related to OpamRepositoryRoot

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

true, and it is erroneous, the good fix would be :

Suggested change
OpamRepositoryRoot.Dir.Op.(repo_root / upgradeto_version_string)
OpamRepositoryRoot.Dir.Op.(OpamRepositoryRoot.Dir.basename repo_root / upgradeto_version_string)

Should we extract it in another PR or have it in a separate commit in this PR ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

oh, i just saw that it was already in a separate commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

erroneous? I don't think so, the code as it was there was fine. basename repo_root would result in a totally different behaviour and bring a potential bug

@kit-ty-kate
kit-ty-kate force-pushed the abstract-repository-root branch 2 times, most recently from 481a6a2 to 3793831 Compare May 15, 2026 21:56
kit-ty-kate and others added 2 commits May 21, 2026 12:09
…tory formats

Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
…tors

Co-authored-by: Kate <kit-ty-kate@exn.st>
@rjbou
rjbou force-pushed the abstract-repository-root branch from 3793831 to 1a2a0e7 Compare May 21, 2026 10:10
rjbou pushed a commit to ocaml-opam/opam-rt that referenced this pull request May 21, 2026
rjbou pushed a commit to ocaml-opam/opam-rt that referenced this pull request May 21, 2026
@rjbou
rjbou merged commit 0c2796c into ocaml:master May 22, 2026
106 of 116 checks passed
rjbou added a commit to ocaml-opam/opam-rt that referenced this pull request May 23, 2026
Apply API change from ocaml/opam#6680 : add OpamRepositoryRoot abstraction
@kit-ty-kate
kit-ty-kate deleted the abstract-repository-root branch July 30, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants