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