╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ PatchRev.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
188 var iter = try ids.iteratorFromIndex(0); 189 while (try iter.next()) |cursor| { 190 const id = try evt.readOrderKeyId(DB, cursor); 191 const record = (try readById(DB, hash_kind, haxy_moment, arena, &id)) orelse continue; 192 if (!record.removed) return .{ .id = id, .record = record }; 193 } 194 return null; 195 } 196 197 // squash commits referenced only by patch revision records 198 pub fn gcRoots( 199 comptime DB: type, 200 comptime hash_kind: hash.HashKind, 201 allocator: std.mem.Allocator, 202 haxy_moment: DB.HashMap(.read_only), 203 ) ![][hash.hexLen(hash_kind)]u8 { 204 var roots: std.ArrayList([hash.hexLen(hash_kind)]u8) = .empty; 205 errdefer roots.deinit(allocator); 206 var arena = std.heap.ArenaAllocator.init(allocator); 207 defer arena.deinit(); 208 209 const ids_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, id_set_key)) orelse return try roots.toOwnedSlice(allocator); 210 const ids = try DB.SortedSet(.read_only).init(ids_cursor); 211 var iter = try ids.iteratorFromIndex(0); 212 while (try iter.next()) |cursor| { 213 _ = arena.reset(.retain_capacity); 214 const id = try evt.readOrderKeyId(DB, cursor); 215 const record = (try readById(DB, hash_kind, haxy_moment, &arena, &id)) orelse continue; 216 var oid: [hash.hexLen(hash_kind)]u8 = undefined; 217 if (record.patch_oid.len != oid.len) return error.InvalidOid; 218 @memcpy(&oid, record.patch_oid); 219 try roots.append(allocator, oid); 220 } 221 222 return try roots.toOwnedSlice(allocator); 223 } 224