╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
425 426 fn revisionKey(allocator: std.mem.Allocator, target_branch: []const u8, oid: []const u8) ![]u8 { 427 return std.mem.concat(allocator, u8, &.{ target_branch, "\x00", oid }); 428 } 429 430 fn statusSet( 431 comptime DB: type, 432 statuses: DB.SortedMap(.read_write), 433 status: StatusKind, 434 ) !DB.SortedSet(.read_write) { 435 return DB.SortedSet(.read_write).init(try statuses.putCursor(@tagName(status))); 436 } 437 438 fn removeFromLabelSets( 439 comptime DB: type, 440 label_statuses: DB.SortedMap(.read_write), 441 labels: []const u8, 442 status: StatusKind, 443 order_key: []const u8, 444 ) !void { 445 var label_iter = labelIterator(labels); 446 while (label_iter.next()) |label| { 447 if (label.len == 0 or label.len > label_max_len) continue; 448 var key_buffer: LabelStatusKey = undefined; 449 const key = try labelStatusKey(&key_buffer, label, status); 450 const set = try DB.SortedSet(.read_write).init(try label_statuses.putCursor(key)); 451 _ = try set.remove(order_key); 452 if (0 == try set.count()) _ = try label_statuses.remove(key); 453 } 454 } 455 456 pub fn readById( 457 comptime DB: type, 458 comptime hash_kind: hash.HashKind, 459 haxy_moment: DB.HashMap(.read_only), 460 arena: *std.heap.ArenaAllocator, 461 id: *const [evt.event_id_size]u8, 462 ) !?Record { 463 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 464 const records = try DB.HashMap(.read_only).init(records_cursor); 465 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, id)) orelse return null; 466 return try evt.read(Record, DB, hash_kind, arena, try DB.HashMap(.read_only).init(record_cursor)); 467 } 468