╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1276 var ours_values = values; 1277 ours_values[0].title = "Drop the legacy configuration loader"; 1278 ours_values[0].tags = "cleanup config breaking"; 1279 const closed_description = try longDescription( 1280 patch_arena.allocator(), 1281 "Cache parsed manifests for the lifetime of a command invocation and invalidate entries when their files change.", 1282 ); 1283 ours_values[1].description = closed_description; 1284 ours_values[2].description = "Add JSON output to inspect with versioned field names and deterministic object ordering."; 1285 var theirs_values = values; 1286 theirs_values[0].title = "Delete compatibility configuration support"; 1287 theirs_values[0].tags = "config maintenance"; 1288 theirs_values[1].description = "Keep a process-wide manifest cache shared by every command and refresh it after writes."; 1289 theirs_values[2].description = "Expose inspect results as newline-delimited JSON so callers can stream large repositories."; 1290 1291 const seed_tip = (try target_repo.readRef(io, evt.events_ref)) orelse return error.NotFound; 1292 const other_ref = xit.ref.Ref{ .kind = .head, .name = "haxy/patch-other" }; 1293 var ours = [_]evt.EventWithId{ 1294 .{ 1295 .id = std.fmt.bytesToHex(patch_ids[1], .lower), 1296 .timestamp = 800, 1297 .author = .{ .name = "alice", .email = "alice@example.test" }, 1298 .event = .{ .patch = ours_values[0] }, 1299 }, 1300 .{ 1301 .id = std.fmt.bytesToHex(patch_ids[2], .lower), 1302 .timestamp = 801, 1303 .author = .{ .name = "alice", .email = "alice@example.test" }, 1304 .event = .{ .patch = ours_values[1] }, 1305 }, 1306 .{ 1307 .id = std.fmt.bytesToHex(patch_ids[3], .lower), 1308 .timestamp = 802, 1309 .author = .{ .name = "alice", .email = "alice@example.test" }, 1310 .event = .{ .patch = ours_values[2] }, 1311 }, 1312 }; 1313 1314 var theirs = ours; 1315 theirs[0].timestamp = 810; 1316 theirs[0].author = .{ .name = "bob", .email = "bob@example.test" }; 1317 theirs[0].event.patch = theirs_values[0]; 1318 theirs[1].timestamp = 811; 1319 theirs[1].author = .{ .name = "bob", .email = "bob@example.test" }; 1320 theirs[1].event.patch = theirs_values[1]; 1321 theirs[2].timestamp = 812; 1322 theirs[2].author = .{ .name = "bob", .email = "bob@example.test" }; 1323 theirs[2].event.patch = theirs_values[2]; 1324 1325 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &ours); 1326 try commitEventsAtRef(io, allocator, target_repo, other_ref, &theirs, seed_tip); 1327 { 1328 var merge = try target_repo.mergeAtRef(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = other_ref }} } } }, evt.events_ref, null); 1329 defer merge.deinit(); 1330 if (merge.result != .success) return error.MergeFailed; 1331 } 1332 try target_repo.removeBranch(io, .{ .name = other_ref.name }); 1333 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &.{}); 1334 try pch.writeBranchPatch(.server, .xit, .{}, io, allocator, target_repo, std.fmt.bytesToHex(evt.EventWithId.randomId(random), .lower), .{ 1335 .title = "Merge the existing feature branch", 1336 .description = "This patch tracks the feature branch in this repo without creating a fork.", 1337 .tags = "feature", 1338 .source_branch = "feature", 1339 .target_branch = "master", 1340 }, null, patch_author); 1341 } 1342 1343 // commit `events` onto `ref`, rooted at `parent`, as one undoable step. 1344 // consume always roots a new branch at nothing, so the divergent fixtures 1345 // write their side branch here instead, recording the action consume would 1346 fn commitEventsAtRef( 1347 io: std.Io, 1348 allocator: std.mem.Allocator, 1349 repo: *rp.Repo(.xit, .{}), 1350 ref: xit.ref.Ref, 1351 events: []const evt.EventWithId, 1352 parent: [hash.hexLen(.sha1)]u8, 1353 ) !void { 1354 const Repo = rp.Repo(.xit, .{}); 1355 const DB = Repo.DB; 1356 const Ctx = struct { 1357 core: *Repo.Core, 1358 io: std.Io, 1359 allocator: std.mem.Allocator, 1360 ref: xit.ref.Ref, 1361 events: []const evt.EventWithId, 1362 parent: [hash.hexLen(.sha1)]u8, 1363 1364 pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void { 1365 var moment = try DB.HashMap(.read_write).init(cursor.*); 1366 const state = Repo.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; 1367 try evt.commitEvents(.xit, .{}, state, ctx.io, ctx.allocator, ctx.ref, ctx.events, .{ctx.parent}); 1368 try xit.undo.write(.{}, state, std.Io.Timestamp.now(ctx.io, .real).toSeconds(), .{ .custom = .{ .action = evt.undo_action } }); 1369 } 1370 }; 1371 1372 try repo.core.db_file.lock(io, .exclusive); 1373 defer repo.core.db_file.unlock(io); 1374 1375 const history = try DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); 1376 try history.appendContext(.{ .slot = try history.getSlot(-1) }, Ctx{ 1377 .core = &repo.core, 1378 .io = io, 1379 .allocator = allocator, 1380 .ref = ref, 1381 .events = events, 1382 .parent = parent, 1383 }); 1384 } 1385 1386 // recursively copy the contents of src_dir into dest_dir 1387 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 1388 var iter = src_dir.iterate(); 1389 while (try iter.next(io)) |entry| { 1390 switch (entry.kind) { 1391 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 1392 .directory => { 1393 try dest_dir.createDirPath(io, entry.name); 1394 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1395 defer dest_entry_dir.close(io); 1396 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1397 defer src_entry_dir.close(io); 1398 try copyDir(io, src_entry_dir, dest_entry_dir); 1399 }, 1400 else => {}, 1401 } 1402 } 1403 } 1404