╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1388 } 1389 1390 // visit target commits oldest first, attributing each revision to the 1391 // commit that introduced it; the shared iterator visits each ancestor once 1392 var revision_key_buffer: [rf.MAX_REF_CONTENT_SIZE + 1 + hash.hexLen(repo_opts.hash)]u8 = undefined; 1393 while (targets.pop()) |target| { 1394 try commits.include(&target.after_oid); 1395 while (try commits.next(arena.allocator())) |commit| { 1396 defer commit.deinit(); 1397 1398 // find patches whose selected revision matches this commit. 1399 const key = try std.fmt.bufPrint(&revision_key_buffer, "{s}\x00{s}", .{ update.ref_name[heads_prefix.len..], &commit.oid }); 1400 const ids_cursor = try revisions.getCursor(hash.hashInt(repo_opts.hash, key)) orelse continue; 1401 const ids = try DB.CountedHashSet(.read_only).init(ids_cursor); 1402 var ids_iter = try ids.iterator(); 1403 while (try ids_iter.next()) |cursor| { 1404 const pair = try cursor.readKeyValuePair(); 1405 var patch_id: [evt.event_id_size]u8 = undefined; 1406 if ((try pair.key_cursor.readBytes(&patch_id)).len != patch_id.len) return error.InvalidPatch; 1407 const patch_hex = std.fmt.bytesToHex(patch_id, .lower); 1408 1409 // a fast-forward has no recorded merge boundary; use the old ref tip 1410 const before_oid = if (std.mem.eql(u8, &commit.oid, &target.after_oid)) &old_oid else &target.before_oid; 1411 importMerged(repo_opts, state, db, moment, io, allocator, repo_root_path, &patch_id, &commit.oid, before_oid, &target.after_oid) catch |err| { 1412 serve_common.logError(io, error_writer, "failed to mark patch {s} as merged: {s}\n", .{ &patch_hex, @errorName(err) }); 1413 continue; 1414 }; 1415 } 1416 } 1417 } 1418 } 1419 } 1420