╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────╮ │src/patch.zig│ ╰─────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │248 } │ │249 │ │250 // import the revision and mark the patch merged │ │251 - if (!try importMergedFromFork(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.fork_repo, &ctx.patch_id, ctx.expected_patch, ctx.author, ctx.timestamp)) return error.PatchOutOfDate; │ │251 + if (!try importMergedFromFork(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.fork_repo, &ctx.patch_id, &ctx.merge_oid, ctx.expected_patch, ctx.author, ctx.timestamp)) return error.PatchOutOfDate;│ │252 │ │253 // merge the selected commit │ │254 { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────╮ │325 allocator: std.mem.Allocator, │ │326 repo_root_path: []const u8, │ │327 patch_id: *const [evt.event_id_size]u8, │ │328 + merged_oid: *const [hash.hexLen(repo_opts.hash)]u8, │ │329 ) !void { │ │330 var arena = std.heap.ArenaAllocator.init(allocator);│ │331 defer arena.deinit(); │ ╰─────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │335 var fork_repo = try rp.Repo(.xit, repo_opts).open(io, allocator, .{ .path = fork_path, .require_repo_root = true }); │ │336 defer fork_repo.deinit(io, allocator); │ │337 │ │337 - _ = try importMergedFromFork(repo_opts, state, db, moment, io, allocator, &fork_repo, patch_id, null, null, 0); │ │338 + _ = try importMergedFromFork(repo_opts, state, db, moment, io, allocator, &fork_repo, patch_id, merged_oid, null, null, 0);│ │339 } │ │340 │ │341 // import the revision and mark its patch merged in the current transaction │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────╮ │348 allocator: std.mem.Allocator, │ │349 fork_repo: *rp.Repo(.xit, repo_opts), │ │350 patch_id: *const [evt.event_id_size]u8, │ │351 + merged_oid: *const [hash.hexLen(repo_opts.hash)]u8,│ │352 expected_patch: ?evt.Patch, │ │353 merged_author: ?evt.CommitAuthor, │ │354 merged_timestamp: u64, │ ╰────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │360 const haxy_moment = try evt.currentMomentFromRepoMoment(repo_opts.hash, moment.readOnly()); │ │361 const patch_record = (try evt.Patch.readById(DB, repo_opts.hash, haxy_moment, &arena, patch_id)) orelse return false;│ │362 const selected = patch_record.event.revision orelse return false; │ │361 - if (patch_record.removed or patch_record.event.status == .merged) return false; │ │363 + if (patch_record.removed or patch_record.event.status.kind() == .merged) return false; │ │364 if (expected_patch) |expected| { │ │365 if (!evt.fieldEqual(evt.Patch, expected, patch_record.event)) return false; │ │366 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │367 const revision_id = try evt.parseEventId(&selected.id); │ │368 + if (!selected.includesOid(merged_oid)) return false; │ │369 │ │370 const fork_moment = try evt.currentMoment(repo_opts, fork_repo); │ │371 const revision = (try evt.PatchRev.readById(DB, repo_opts.hash, fork_moment, &arena, &revision_id)) orelse return false;│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │404 } │ │405 │ │406 var patch = patch_record.event; │ │404 - patch.status = .merged; │ │407 + patch.status = .{ .merged = merged_oid }; │ │408 events[event_count] = .{ │ │409 .id = std.fmt.bytesToHex(patch_id.*, .lower), │ │410 .timestamp = if (merged_author != null) merged_timestamp else @intCast(std.Io.Timestamp.now(io, .real).toSeconds()),│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │467 var patch_id: [evt.event_id_size]u8 = undefined; │ │468 if ((try pair.key_cursor.readBytes(&patch_id)).len != patch_id.len) return error.InvalidPatch; │ │469 const patch_hex = std.fmt.bytesToHex(patch_id, .lower); │ │467 - importMerged(repo_opts, state, db, moment, io, allocator, repo_root_path, &patch_id) catch |err| { │ │470 + importMerged(repo_opts, state, db, moment, io, allocator, repo_root_path, &patch_id, &commit.oid) catch |err| { │ │471 serve_common.logError(io, error_writer, "failed to mark patch {s} as merged: {s}\n", .{ &patch_hex, @errorName(err) });│ │472 continue; │ │473 }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │311 .{ .tree = .{ .name = "head", .oid = &source_b_tree } }, │ │312 }; │ │313 var parent_patch = updated_patch; │ │314 - parent_patch.status = .merged; │ │314 + parent_patch.status = .{ .merged = &source_b_oid }; │ │315 { │ │316 try consumePatchWithRevision(.repo, io, allocator, &target, side_events_ref, patchrev_b_id, .{│ │317 .base_oid = &base_oid, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │426 .event = .{ .patch = closed_child }, │ │427 }}); │ │428 var merged_child = child.event; │ │429 - merged_child.status = .merged; │ │429 + merged_child.status = .{ .merged = (child.event.revision orelse return error.NotFound).source_oid };│ │430 try evt.consume(.repo, .xit, repo_opts, io, allocator, &target, status_side_ref, &.{.{ │ │431 .id = std.fmt.bytesToHex(child_id, .lower), │ │432 .timestamp = 15, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯