╭ changed ──────────╮ │src/event/Patch.zig│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │156 + │ │157 +pub fn resolveMerge( │ │158 + target: Self, │ │159 + parent: Self, │ │160 + merged: *Self, │ │161 + outcome: *[std.meta.fields(Self).len]evt.FieldMerge, │ │162 +) void { │ │163 + const status_index = std.meta.fieldIndex(Self, "status") orelse @compileError("Patch.status not found"); │ │164 + const patchrev_index = std.meta.fieldIndex(Self, "patchrev_id") orelse @compileError("Patch.patchrev_id not found");│ │165 + if (outcome[status_index] != .conflicted or outcome[patchrev_index] == .conflicted) return; │ │166 │ │167 + if (target.status == .merged and std.meta.eql(target.patchrev_id, merged.patchrev_id)) { │ │168 + merged.status = .merged; │ │169 + outcome[status_index] = .kept; │ │170 + } else if (parent.status == .merged and std.meta.eql(parent.patchrev_id, merged.patchrev_id)) { │ │171 + merged.status = .merged; │ │172 + outcome[status_index] = .parent; │ │173 + } │ │174 +} │ │175 + │ │176 +fn statusSet( │ │177 + comptime DB: type, │ │178 + statuses: DB.SortedMap(.read_write), │ │179 + status: Status, │ │180 +) !DB.SortedSet(.read_write) { │ │181 + return DB.SortedSet(.read_write).init(try statuses.putCursor(@tagName(status))); │ │182 +} │ │183 + │ │184 +fn removeFromTagSets( │ │185 + comptime DB: type, │ │186 + tag_statuses: DB.SortedMap(.read_write), │ │187 + tags: []const u8, │ │188 + status: Status, │ │189 + order_key: []const u8, │ │190 +) !void { │ │191 + var tag_iter = tagIterator(tags); │ │192 + while (tag_iter.next()) |tag| { │ │193 + if (tag.len == 0 or tag.len > tag_max_len) continue; │ │194 + var key_buffer: TagStatusKey = undefined; │ │195 + const key = try tagStatusKey(&key_buffer, tag, status); │ │196 + const set = try DB.SortedSet(.read_write).init(try tag_statuses.putCursor(key)); │ │197 + _ = try set.remove(order_key); │ │198 + if (0 == try set.count()) _ = try tag_statuses.remove(key); │ │199 + } │ │200 +} │ │201 + │ │202 pub fn readById( │ │203 comptime DB: type, │ │204 comptime hash_kind: hash.HashKind, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯