╭ changed ──╮ │src/try.zig│ ╰───────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │814 try evt.consume(.local, .repo, .xit, .{}, io, allocator, &template_repo, evt.events_ref, &discussion_comment_events); │ │815 try template_repo.patchAll(io, allocator, null); │ │816 try template_repo.addConfig(io, allocator, .{ .name = "core.bare", .value = "true" }); │ │817 - // fixtures commit directly, so index the ref tips by hand │ │818 - try find.refresh(.{}, io, allocator, &template_repo); │ │819 - try srch_cmmt.refresh(.{}, io, allocator, &template_repo); │ │817 + try transaction(io, &template_repo, Reindex{ .io = io, .allocator = allocator, .core = &template_repo.core, .commits = true });│ │818 // clear history only after indexing has written its transactions. │ │819 { │ │820 const moment = try evt.currentMoment(.{}, &template_repo); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1069 } │ │1070 try fork_repo.patchAll(io, allocator, null); │ │1071 try fork_repo.addConfig(io, allocator, .{ .name = "core.bare", .value = "true" }); │ │1074 - // the commits above skipped the push path, so index the patch branch by hand │ │1075 - try find.refresh(.{}, io, allocator, &fork_repo); │ │1072 + try transaction(io, &fork_repo, Reindex{ .io = io, .allocator = allocator, .core = &fork_repo.core, .commits = false });│ │1073 _ = try fork_repo.garbageCollect(io, allocator, .{}); │ │1074 try fork_dir.deleteFile(io, path); │ │1075 const revision_id = evt.EventWithId.randomId(random); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1457 │ │1458 // append `ctx` to the repo's history as one transaction. the fixtures write a │ │1459 // few states the normal paths have no way to produce │ │1460 +// fixtures commit directly, so the ref tips are indexed by hand. a fork gets │ │1461 +// no commit index, as in production. │ │1462 +const Reindex = struct { │ │1463 + io: std.Io, │ │1464 + allocator: std.mem.Allocator, │ │1465 + core: *rp.Repo(.xit, .{}).Core, │ │1466 + commits: bool, │ │1467 + │ │1468 + pub fn run(ctx: @This(), cursor: *rp.Repo(.xit, .{}).DB.Cursor(.read_write)) !void { │ │1469 + var moment = try rp.Repo(.xit, .{}).DB.HashMap(.read_write).init(cursor.*); │ │1470 + const state = rp.Repo(.xit, .{}).State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; │ │1471 + _ = try find.refreshInTransaction(.{}, state, &moment, ctx.io, ctx.allocator, null); │ │1472 + if (ctx.commits) _ = try srch_cmmt.refreshInTransaction(.{}, state, &moment, ctx.io, ctx.allocator, &.{}, null);│ │1473 + } │ │1474 +}; │ │1475 + │ │1476 fn transaction(io: std.Io, repo: *rp.Repo(.xit, .{}), ctx: anytype) !void { │ │1477 const DB = rp.Repo(.xit, .{}).DB; │ │1478 try repo.core.db_file.lock(io, .exclusive); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯