╭ changed ────────────╮ │src/search_commit.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │ 7 const rf = xit.ref; │ │ 8 const obj = xit.object; │ │ 9 const mrg = xit.merge; │ │10 +const serve_common = @import("serve_common.zig"); │ │11 │ │12 // the repo moment key holding one commit-message index per ref tip. it sits │ │13 // outside the haxy moment because pushes change it and events never do. each│ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │86 pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void { │ │87 var moment = try DB.HashMap(.read_write).init(cursor.*); │ │88 const state = Repo.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; │ │88 - if (!try refreshInTransaction(repo_opts, state, &moment, ctx.io, ctx.allocator, ctx.updates)) return error.CancelTransaction; │ │89 + if (!try refreshInTransaction(repo_opts, state, &moment, ctx.io, ctx.allocator, ctx.updates, null)) return error.CancelTransaction; │ │90 │ │91 // record the user action for undo │ │92 try xit.undo.write(repo_opts, state, std.Io.Timestamp.now(ctx.io, .real).toSeconds(), .{ .custom = .{ .action_kind = undo_action } });│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────╮ │116 io: std.Io, │ │117 allocator: std.mem.Allocator, │ │118 updates: ?[]const xit.net_server_receive_pack.AppliedRefUpdate,│ │119 + progress_ctx_maybe: ?repo_opts.ProgressCtx, │ │120 ) !bool { │ │121 const Repo = rp.Repo(.xit, repo_opts); │ │122 const DB = Repo.DB; │ ╰────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │253 │ │254 var diff_arena = std.heap.ArenaAllocator.init(allocator); │ │255 defer diff_arena.deinit(); │ │254 - const diff = try commitDiff(repo_opts, state.readOnly(), io, allocator, diff_arena.allocator(), if (base) |*base_oid| base_oid else null, &item.oid); │ │256 + const diff = try commitDiff(repo_opts, state.readOnly(), io, allocator, diff_arena.allocator(), if (base) |*base_oid| base_oid else null, &item.oid, progress_ctx_maybe);│ │257 + │ │258 + // the walk is done, so the messages left to read are the total │ │259 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .text = "Indexing commits" }); │ │260 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = diff.removed.len + diff.added.len } }); │ │261 for (diff.removed) |commit| { │ │262 + defer serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .complete_one = .writing_patch }); │ │263 const key = try readPosting(repo_opts, state.readOnly(), io, allocator, &message, commit); │ │264 try srch.remove(DB, version, allocator, &key, message.items); │ │265 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │266 for (diff.added) |commit| { │ │267 + defer serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .complete_one = .writing_patch });│ │268 const key = try readPosting(repo_opts, state.readOnly(), io, allocator, &message, commit); │ │269 try srch.add(DB, version, allocator, &key, message.items); │ │270 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │271 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .end = .writing_patch });│ │272 │ │273 try versions.append(aa, .{ .oid = item.oid, .timestamp = item.timestamp }); │ │274 // the next version copies this one's slot, so everything │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │355 aa: std.mem.Allocator, │ │356 base_tip: ?*const [hash.hexLen(repo_opts.hash)]u8, │ │357 tip: *const [hash.hexLen(repo_opts.hash)]u8, │ │358 + progress_ctx_maybe: ?repo_opts.ProgressCtx, │ │359 ) !struct { removed: []const Commit(repo_opts.hash), added: []const Commit(repo_opts.hash) } {│ │360 var removed: std.ArrayList(Commit(repo_opts.hash)) = .empty; │ │361 var added: std.ArrayList(Commit(repo_opts.hash)) = .empty; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │394 } │ │395 } │ │396 } else { │ │397 + // a whole history has no count until it is walked, so the walk reports │ │398 + // the commits it has reached so far │ │399 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .text = "Walking commits" }); │ │400 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = 0 } });│ │401 var iter = try obj.ObjectIterator(.xit, repo_opts).init(state, io, allocator, .{ .kind = .commit }); │ │402 defer iter.deinit(); │ │403 try iter.include(tip); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │404 while (try iter.next(allocator)) |object| { │ │405 defer object.deinit(); │ │406 try added.append(aa, .{ .oid = object.oid, .timestamp = object.content.commit.metadata.timestamp });│ │407 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .complete_one = .writing_patch });│ │408 } │ │409 + serve_common.reportProgress(repo_opts, io, progress_ctx_maybe, .{ .end = .writing_patch }); │ │410 } │ │411 │ │412 return .{ .removed = removed.items, .added = added.items }; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯