╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────╮ │src/patch.zig│ ╰─────────────╯ ╭───────────────────────────────────────────────╮ │490 │ │449 -fn refreshMergeChecks( │ │491 +fn refreshOpenMergeChecks( │ │492 comptime repo_opts: rp.RepoOpts(.xit),│ │493 io: std.Io, │ │494 allocator: std.mem.Allocator, │ ╰───────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │495 target_repo: *rp.Repo(.xit, repo_opts), │ │454 - id_maybe: ?[evt.event_id_size]u8, │ │496 + progress_ctx_maybe: ?repo_opts.ProgressCtx, │ │497 ) !void { │ │456 - if (id_maybe) |id| return refreshMergeCheck(repo_opts, io, allocator, target_repo, &id); │ │457 - │ │498 // collect open patch ids before any refresh changes the database │ │499 const DB = evt.EventDB(repo_opts.hash); │ │460 - const moment = evt.currentMoment(repo_opts, target_repo) catch |err| switch (err) { │ │461 - error.NotFound => return, │ │462 - else => return err, │ │463 - }; │ │464 - const statuses_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, evt.Patch.status_to_id_set_key)) orelse return; │ │465 - const statuses = try DB.SortedMap(.read_only).init(statuses_cursor); │ │466 - const open_cursor = try statuses.getCursor("open") orelse return; │ │467 - const open = try DB.SortedSet(.read_only).init(open_cursor); │ │500 var ids: std.ArrayList([evt.event_id_size]u8) = .empty; │ │501 defer ids.deinit(allocator); │ │470 - var iter = try open.iteratorFromIndex(0); │ │471 - while (try iter.next()) |cursor| try ids.append(allocator, try evt.readOrderKeyId(DB, cursor)); │ │502 + collect: { │ │503 + const moment = evt.currentMoment(repo_opts, target_repo) catch |err| switch (err) { │ │504 + error.NotFound => break :collect, │ │505 + else => return err, │ │506 + }; │ │507 + const statuses_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, evt.Patch.status_to_id_set_key)) orelse break :collect; │ │508 + const statuses = try DB.SortedMap(.read_only).init(statuses_cursor); │ │509 + const open_cursor = try statuses.getCursor("open") orelse break :collect; │ │510 + const open = try DB.SortedSet(.read_only).init(open_cursor); │ │511 + var iter = try open.iteratorFromIndex(0); │ │512 + while (try iter.next()) |cursor| try ids.append(allocator, try evt.readOrderKeyId(DB, cursor)); │ │513 + } │ │514 │ │515 + // start progress reporting after the patch count is known │ │516 + if (repo_opts.ProgressCtx != void) { │ │517 + if (progress_ctx_maybe) |progress_ctx| progress_ctx.run(io, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = ids.items.len } }) catch {};│ │518 + } │ │519 + │ │520 // refresh each collected patch independently │ │474 - for (ids.items) |id| refreshMergeability(repo_opts, io, allocator, target_repo, id); │ │521 + for (ids.items) |id| { │ │522 + refreshMergeability(repo_opts, io, allocator, target_repo, id); │ │523 + if (repo_opts.ProgressCtx != void) { │ │524 + if (progress_ctx_maybe) |progress_ctx| progress_ctx.run(io, .{ .complete_one = .writing_patch }) catch {}; │ │525 + } │ │526 + } │ │527 + │ │528 + // finish progress reporting after all patches have been visited │ │529 + if (repo_opts.ProgressCtx != void) { │ │530 + if (progress_ctx_maybe) |progress_ctx| progress_ctx.run(io, .{ .end = .writing_patch }) catch {}; │ │531 + } │ │532 } │ │533 │ │534 fn refreshMergeCheck( │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────╮ │1124 } │ │1125 │ │1126 // refresh other patches affected by the updated target branch. │ │1070 - refreshMergeability(repo_opts, io, allocator, target_repo, null); │ │1127 + refreshOpenMergeability(repo_opts, io, allocator, target_repo, null);│ │1128 │ │1129 // the merge moved the target branch, so its indexes follow │ │1130 find.refresh(repo_opts, io, allocator, target_repo) catch |err| { │ ╰───────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───╮ │src/push.zig│ ╰────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │145 try pch.detectMerged(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.repo_root_path, ctx.updates.items.items, ctx.error_writer);│ │146 │ │147 // the revisions the pushed branches cause belong to the push │ │148 - try pch.refreshBranchesInTransaction(repo_opts, state, &moment, ctx.io, ctx.allocator, ctx.updates.items.items); │ │148 + _ = try pch.refreshBranchesInTransaction(.server, repo_opts, state, &moment, ctx.io, ctx.allocator, ctx.updates.items.items, null); │ │149 } │ │150 try writeUndo(repo_opts, state, ctx.io, ctx.allocator, ctx.author); │ │151 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │182 var progress = PushProgress{ .response = &response, .writer = writer, .label = "Updating patches" }; │ │183 pch.refreshBranches(.server, .xit, repo_opts, io, allocator, repo, updates.items.items, &progress) catch |err| {│ │184 serve_common.logError(io, error_writer, "failed to refresh branch patches: {s}\n", .{@errorName(err)}); │ │185 - pch.refreshMergeability(repo_opts, io, allocator, repo, null); │ │185 + pch.refreshOpenMergeability(repo_opts, io, allocator, repo, null); │ │186 }; │ │187 find.refresh(repo_opts, io, allocator, repo) catch |err| { │ │188 serve_common.logError(io, error_writer, "failed to refresh file index: {s}\n", .{@errorName(err)}); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1243 defer detached.deinit(); │ │1244 } │ │1245 try target.removeBranch(io, .{ .name = "master" }); │ │1246 - pch.refreshMergeability(repo_opts, io, allocator, target, null); │ │1246 + pch.refreshOpenMergeability(repo_opts, io, allocator, target, null); │ │1247 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, patch));│ │1248 try expectMergeabilityShortBytes(try target.core.latestMoment(), id); │ │1249 try target.addBranch(io, .{ .name = "master" }); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1251 var restored = try target.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "master" } } });│ │1252 defer restored.deinit(); │ │1253 } │ │1254 - pch.refreshMergeability(repo_opts, io, allocator, target, null); │ │1254 + pch.refreshOpenMergeability(repo_opts, io, allocator, target, null); │ │1255 try std.testing.expectEqualDeep(clean, try readMergeability(target, io, allocator, id, patch)); │ │1256 │ │1257 // a missing fork disables merging without changing the accepted events │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──╮ │src/try.zig│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1373 .timestamp = 820, │ │1374 }, null, .{ .kind = .head, .name = "feature" }); │ │1375 │ │1376 - try pch.refreshBranchesInTransaction(opts, state, &moment, ctx.io, ctx.allocator, null); │ │1376 + _ = try pch.refreshBranchesInTransaction(.server, opts, state, &moment, ctx.io, ctx.allocator, null, null);│ │1377 try push.writeUndo(opts, state, ctx.io, ctx.allocator, ctx.author); │ │1378 } │ │1379 }; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯