╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2361 2362 walk_queue_index += 1; 2363 2364 // if we've seen this object id, skip it 2365 if (null != try seen_object_ids.getCursor(oid_int)) { 2366 continue; 2367 } 2368 2369 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 2370 2371 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 2372 defer commit_object.deinit(); 2373 2374 // if this object id has already been consumed, skip it 2375 if (null != try consumed_object_ids.getCursor(oid_int)) { 2376 continue; 2377 } 2378 2379 if (self.newest_object_id == null) self.newest_object_id = oid; 2380 self.oldest_object_id = oid; 2381 2382 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 2383 var pending_parent_count: u64 = 0; 2384 for (parent_oids) |*parent_oid| { 2385 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2386 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 2387 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 2388 2389 // if this object id has already been consumed, skip it 2390 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 2391 continue; 2392 } 2393 2394 // if this object id hasn't already been seen, add it to the walk queue 2395 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 2396 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 2397 } 2398 2399 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 2400 const children = try TempDB.HashSet(.read_write).init(children_cursor); 2401 try children.put(oid_int, .{ .bytes = &oid }); 2402 pending_parent_count += 1; 2403 } 2404 2405 if (pending_parent_count == 0) { 2406 try self.ready_queue.append(.{ .bytes = &oid }); 2407 } else { 2408 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 2409 } 2410 } 2411 } 2412 2413 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 2414 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 2415 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 2416 const children = try TempDB.HashSet(.read_only).init(children_cursor); 2417 var children_iter = try children.iterator(); 2418 2419 while (try children_iter.next()) |*child_cursor| { 2420 const kv_pair = try child_cursor.readKeyValuePair(); 2421 const child_oid_int = kv_pair.hash; 2422 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 2423 const pending_parent_count = try pending_parent_cursor.readUint(); 2424 2425 if (pending_parent_count <= 1) { 2426 _ = try self.child_to_pending_parents.remove(child_oid_int); 2427 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 2428 try self.ready_queue.append(.{ .bytes = &child_oid }); 2429 } else { 2430 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 2431 } 2432 } 2433 } 2434 2435 fn readOidFromList(list: TempDB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 2436 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 2437 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2438 _ = try oid_cursor.readBytes(&oid); 2439 return oid; 2440 } 2441 }; 2442 } 2443