From e1053c6881da1bba409a16783e01a89248507a66 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 7 Jun 2026 10:32:26 +0900 Subject: refactor(phase-c): share PlatformRepository and RepositorySet via handles PHP shares a single PlatformRepository by reference across the RepositorySet, createRequest, VersionSelector, and (in show) the installed repository. The port worked with owned values / &mut, so it could not share: create_repository_set silently dropped the platform repo from the pool (PlatformRepository is not Clone), show rebuilt a fresh PlatformRepository per use, and the package discovery / show version selectors were stubbed because VersionSelector wanted an owned RepositorySet. Thread the existing PlatformRepositoryHandle (Rc>) through installer.rs and show, restoring the RootPackageRepository + platform repo registration and implementing same_repository via RepositoryInterfaceHandle ptr_eq. Hold package-discovery repos as a shared RepositoryInterfaceHandle, and share RepositorySet as Rc> in the set caches and VersionSelector (which only reads it), unblocking both stubbed selector sites and dropping show's placeholder set. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/require_command.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/command/require_command.rs') diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 871b07a..b3ad6cf 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -61,11 +61,13 @@ pub struct RequireCommand { } impl PackageDiscoveryTrait for RequireCommand { - fn get_repos_mut(&mut self) -> &mut Option { + fn get_repos_mut(&mut self) -> &mut Option { todo!() } - fn get_repository_sets_mut(&mut self) -> &mut IndexMap { + fn get_repository_sets_mut( + &mut self, + ) -> &mut IndexMap>> { todo!() } @@ -280,7 +282,9 @@ impl RequireCommand { for repo in repos { combined.push(repo.clone()); } - *self.get_repos_mut() = Some(CompositeRepository::new(combined)); + *self.get_repos_mut() = Some(crate::repository::RepositoryInterfaceHandle::new( + CompositeRepository::new(combined), + )); let preferred_stability = if composer.get_package().get_prefer_stable() { "stable".to_string() @@ -1033,14 +1037,14 @@ impl RequireCommand { let locker_is_locked = composer.get_locker().borrow_mut().is_locked(); let mut requirements: IndexMap = IndexMap::new(); let mut version_selector = VersionSelector::new( - RepositorySet::new( + std::rc::Rc::new(std::cell::RefCell::new(RepositorySet::new( "stable", IndexMap::new(), vec![], IndexMap::new(), IndexMap::new(), IndexMap::new(), - ), + ))), None, )?; let repo: crate::repository::RepositoryInterfaceHandle = if locker_is_locked { -- cgit v1.3.1