| ... | @@ -142,7 +142,8 @@ pub const JobQueue = struct { | ... | @@ -142,7 +142,8 @@ pub const JobQueue = struct { |
| 142 | /// Set of hashes that will be additionally fetched even if they are marked | 142 | /// Set of hashes that will be additionally fetched even if they are marked |
| 143 | /// as lazy. | 143 | /// as lazy. |
| 144 | unlazy_set: UnlazySet = .{}, | 144 | unlazy_set: UnlazySet = .{}, |
| 145 | /// Identifies paths that override all packages in the tree matching | 145 | /// Identifies paths that override all packages in the tree with matching |
| | 146 | /// project ids. |
| 146 | fork_set: ForkSet = .{}, | 147 | fork_set: ForkSet = .{}, |
| 147 | | 148 | |
| 148 | pub const Mode = enum { | 149 | pub const Mode = enum { |
| ... | @@ -173,6 +174,17 @@ pub const JobQueue = struct { | ... | @@ -173,6 +174,17 @@ pub const JobQueue = struct { |
| 173 | return a_project_id.eql(&b_project_id); | 174 | return a_project_id.eql(&b_project_id); |
| 174 | } | 175 | } |
| 175 | }; | 176 | }; |
| | 177 | |
| | 178 | pub const Adapter = struct { |
| | 179 | pub fn hash(_: @This(), a: Package.ProjectId) u32 { |
| | 180 | return @truncate(a.hash()); |
| | 181 | } |
| | 182 | |
| | 183 | pub fn eql(_: @This(), a_project_id: Package.ProjectId, b: Fork, _: usize) bool { |
| | 184 | const b_project_id: Package.ProjectId = .init(b.manifest.name, b.manifest.id); |
| | 185 | return a_project_id.eql(&b_project_id); |
| | 186 | } |
| | 187 | }; |
| 176 | }; | 188 | }; |
| 177 | | 189 | |
| 178 | pub fn deinit(jq: *JobQueue) void { | 190 | pub fn deinit(jq: *JobQueue) void { |
| ... | @@ -558,6 +570,15 @@ pub fn run(f: *Fetch) RunError!void { | ... | @@ -558,6 +570,15 @@ pub fn run(f: *Fetch) RunError!void { |
| 558 | var resource_buffer: [init_resource_buffer_size]u8 = undefined; | 570 | var resource_buffer: [init_resource_buffer_size]u8 = undefined; |
| 559 | | 571 | |
| 560 | if (remote.hash) |expected_hash| { | 572 | if (remote.hash) |expected_hash| { |
| | 573 | const expected_project_id: Package.ProjectId = expected_hash.projectId(); |
| | 574 | if (job_queue.fork_set.getKeyPtrAdapted(expected_project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| { |
| | 575 | f.package_root = fork.path; |
| | 576 | f.manifest_ast = fork.manifest_ast; |
| | 577 | f.manifest = fork.manifest; |
| | 578 | if (!job_queue.recursive) return; |
| | 579 | return queueJobsForDeps(f); |
| | 580 | } |
| | 581 | |
| 561 | const package_root = try job_queue.root_pkg_path.join(arena, expected_hash.toSlice()); | 582 | const package_root = try job_queue.root_pkg_path.join(arena, expected_hash.toSlice()); |
| 562 | if (package_root.root_dir.handle.access(io, package_root.sub_path, .{})) |_| { | 583 | if (package_root.root_dir.handle.access(io, package_root.sub_path, .{})) |_| { |
| 563 | assert(f.lazy_status != .unavailable); | 584 | assert(f.lazy_status != .unavailable); |