╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
760 // merge commit, can still be walked until they hit a consumed commit 761 // or run out of history. 762 if (null != try haxy_moments.getCursor(oid_int)) { 763 try commit_iter.exclude(&commit_object.oid); 764 continue; 765 } 766 767 if (self.newest_object_id == null) self.newest_object_id = oid; 768 self.oldest_object_id = oid; 769 770 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 771 var pending_parent_count: u64 = 0; 772 for (parent_oids) |*parent_oid| { 773 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 774 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 775 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 776 777 if (null != try haxy_moments.getCursor(parent_oid_int)) continue; 778 779 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 780 const children = try DB.CountedHashSet(.read_write).init(children_cursor); 781 try children.put(oid_int, .{ .bytes = &oid }); 782 pending_parent_count += 1; 783 } 784 785 if (pending_parent_count == 0) { 786 try self.oid_queue.put(allocator, oid, {}); 787 } else { 788 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 789 } 790 } 791 } 792 793 fn enqueueChildren(self: *Self, oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 794 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 795 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 796 const children = try DB.CountedHashSet(.read_only).init(children_cursor); 797 var children_iter = try children.iterator(); 798 799 while (try children_iter.next()) |*child_cursor| { 800 const kv_pair = try child_cursor.readKeyValuePair(); 801 const child_oid_int = kv_pair.hash; 802 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 803 const pending_parent_count = try pending_parent_cursor.readUint(); 804 805 if (pending_parent_count <= 1) { 806 _ = try self.child_to_pending_parents.remove(child_oid_int); 807 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 808 try self.oid_queue.put(self.allocator, child_oid, {}); 809 } else { 810 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 811 } 812 } 813 } 814 }; 815 } 816