╭ changed ───╮ │src/push.zig│ ╰────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │13 const serve_common = @import("serve_common.zig"); │ │14 const ssh = @import("serve_ssh_protocol.zig"); │ │15 const progress = @import("./progress.zig"); │ │16 +const notify = @import("notify.zig"); │ │17 │ │18 // prepare all reachable commits, including history received before patch│ │19 // generation was enabled. this shares the receive-pack transaction. │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │117 writer: *std.Io.Writer, │ │118 options: xit.net_server_receive_pack.Options,│ │119 author: evt.CommitAuthor, │ │120 + pusher_id: *const [evt.event_id_size]u8, │ │121 server: evt.Host.Server, │ │122 error_writer: *std.Io.Writer, │ │123 sess: ?*ssh.SessionCtx, │ ╰──────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │132 defer updates.deinit(); │ │133 │ │134 var sideband = progress.Sideband{ .response = &response, .writer = writer, .sess = sess };│ │135 + // the moment index the pushed events were consumed into │ │136 + var moment_index: ?u64 = null; │ │137 const Ctx = struct { │ │138 updates: *xit.net_server_receive_pack.AppliedRefUpdates, │ │139 core: *rp.Repo(.xit, repo_opts).Core, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │147 server: evt.Host.Server, │ │148 error_writer: *std.Io.Writer, │ │149 sideband: *progress.Sideband, │ │150 + moment_index: *?u64, │ │151 │ │152 pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void {│ │153 var moment = try DB.HashMap(.read_write).init(cursor.*); │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │164 // no-op consume must not cancel here, since the push shares the │ │165 // transaction and must commit regardless. │ │166 if (null != try rf.readRecur(.xit, repo_opts, state.readOnly(), ctx.io, .{ .ref = evt.events_ref })) { │ │162 - _ = try evt.consumeInTransaction(.repo, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref); │ │167 + ctx.moment_index.* = evt.consumeInTransaction(.repo, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref) catch |err| switch (err) {│ │168 + error.CancelTransaction => null, │ │169 + else => |e| return e, │ │170 + }; │ │171 try pch.detectMerged(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.server.users_dir, ctx.updates.items.items, ctx.error_writer); │ │172 │ │173 // the revisions the pushed branches cause belong to the push │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────╮ │207 .server = server, │ │208 .error_writer = error_writer, │ │209 .sideband = &sideband, │ │210 + .moment_index = &moment_index,│ │211 }, │ │212 ); │ │213 }; │ ╰───────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │216 if (err == error.CancelTransaction) return; │ │217 return err; │ │218 }; │ │219 + if (moment_index) |index| notify.deliverTransaction(io, allocator, server, repo_opts, repo, index, pusher_id, &sideband); │ │220 evt.bumpRepoActivityAt(io, allocator, server, repo.core.work_path); │ │221 │ │222 pch.refreshBranches(.{ .server = server }, .xit, repo_opts, io, allocator, repo, updates.items.items, &sideband) catch |err| {│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │361 // commit and index any new events │ │362 if (event_count > 0) { │ │363 try evt.commitEvents(.xit, repo_opts, state, ctx.io, ctx.allocator, evt.events_ref, events[0..event_count], null); │ │354 - if (!try evt.consumeInTransaction(.fork, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref)) return error.CancelTransaction;│ │364 + _ = try evt.consumeInTransaction(.fork, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref); │ │365 } │ │366 // the patch branch's file index lands with the push │ │367 _ = try find.refreshInTransaction(repo_opts, state, &moment, ctx.io, ctx.allocator, ctx.sideband); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯