╭ changed ────╮ │src/patch.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────╮ │216 author: evt.CommitAuthor, │ │217 timestamp: u64, │ │218 }; │ │219 - │ │220 -pub const MergeRevision = enum { squash, source }; │ │219 │ │220 pub const Mergeability = struct { │ │221 pub const Status = enum { clean, conflict, unknown };│ ╰──────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │223 source: Status = .unknown, │ │224 squash: Status = .unknown, │ │225 │ │228 - pub fn get(self: Mergeability, revision: MergeRevision) Status { │ │226 + pub fn get(self: Mergeability, revision: evt.Patch.MergeRevision) Status {│ │227 return switch (revision) { │ │228 .source => self.source, │ │229 .squash => self.squash, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────╮ │471 │ │472 pub const MergeInput = struct { │ │473 id: [evt.event_id_size * 2]u8, │ │476 - revision: MergeRevision, │ │474 + revision: evt.Patch.MergeRevision,│ │475 author: evt.CommitAuthor, │ │476 timestamp: u64, │ │477 }; │ ╰───────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │635 var fork_repo_maybe: ?rp.Repo(.xit, repo_opts) = if (patch_record.event.source_branch != null) null else rp.Repo(.xit, repo_opts).open(io, allocator, .{ .path = fork_path, .require_repo_root = true }) catch return error.PatchDataUnavailable;│ │636 defer if (fork_repo_maybe) |*repo| repo.deinit(io, allocator); │ │637 // select the commit and merge identity │ │640 - const merge_oid = oidArray(repo_opts.hash, switch (input.revision) { │ │638 + const selected_oid = oidArray(repo_opts.hash, switch (input.revision) { │ │639 .squash => selected.squash_oid, │ │640 .source => selected.source_oid, │ │641 }) catch return error.InvalidPatch; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────╮ │653 patch_id: [evt.event_id_size]u8, │ │654 expected_patch: evt.Patch, │ │655 target_ref: rf.Ref, │ │658 - merge_oid: [hash.hexLen(repo_opts.hash)]u8, │ │659 - revision: MergeRevision, │ │656 + selected_oid: [hash.hexLen(repo_opts.hash)]u8,│ │657 + revision: evt.Patch.MergeRevision, │ │658 identity: []const u8, │ │659 author: evt.CommitAuthor, │ │660 timestamp: u64, │ ╰───────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │688 const fork_state = State(.read_only){ .core = &repo.core, .extra = .{ .moment = &fork_repo_moment } }; │ │689 var objects = try obj.ObjectIterator(.xit, repo_opts).init(fork_state, ctx.io, ctx.allocator, .{ .kind = .all }); │ │690 defer objects.deinit(); │ │693 - try objects.include(&ctx.merge_oid); │ │691 + try objects.include(&ctx.selected_oid); │ │692 try obj.copyFromObjectIterator(.xit, repo_opts, state, .xit, repo_opts, &objects, ctx.io, null); │ │693 } │ │696 - │ │697 - // import the revision and mark the patch merged │ │698 - if (!try importMergedRevision(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;│ │694 │ │695 // merge the selected commit │ │696 + const before_oid = (try rf.readRecur(.xit, repo_opts, state.readOnly(), ctx.io, .{ .ref = ctx.target_ref })) orelse return error.InvalidTargetBranch; │ │697 { │ │698 var merge_result = try mrg.Merge(.xit, repo_opts).init(state, ctx.io, ctx.allocator, .{ │ │699 .kind = .full, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │704 - .action = .{ .new = .{ .source = &.{.{ .oid = &ctx.merge_oid }}, .algo = .patch } }, │ │700 + .action = .{ .new = .{ .source = &.{.{ .oid = &ctx.selected_oid }}, .algo = .patch } },│ │701 .commit_metadata = .{ │ │702 .author = ctx.identity, │ │703 .committer = ctx.identity, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────╮ │708 defer merge_result.deinit(); │ │709 switch (merge_result.result) { │ │710 .conflict => return error.MergeConflict,│ │715 - .success, .nothing, .fast_forward => {},│ │711 + .success, .fast_forward, .nothing => {},│ │712 .clean => unreachable, │ │713 } │ │714 } │ ╰─────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │715 + const after_oid = (try rf.readRecur(.xit, repo_opts, state.readOnly(), ctx.io, .{ .ref = ctx.target_ref })) orelse return error.InvalidTargetBranch; │ │716 │ │717 + // import the revision and record the target's before/after range │ │718 + if (!try importMergedRevision(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.fork_repo, &ctx.patch_id, .{ .revision = ctx.revision, .before_oid = &before_oid, .after_oid = &after_oid }, ctx.expected_patch, ctx.author, ctx.timestamp)) return error.PatchOutOfDate;│ │719 + │ │720 try xit.undo.writeMessage(repo_opts, state, .{ .custom = "merge patch" }); │ │721 } │ │722 }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │735 .patch_id = patch_id, │ │736 .expected_patch = patch_record.event,│ │737 .target_ref = target_ref, │ │738 - .merge_oid = merge_oid, │ │738 + .selected_oid = selected_oid, │ │739 .revision = input.revision, │ │740 .identity = identity, │ │741 .author = input.author, │ ╰──────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯