╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1232 try std.testing.expectEqual(before_edit + 1, try target.core.db.rootCursor().count()); 1233 const events_before = try target.readRef(io, evt.events_ref); 1234 try std.testing.expectEqualDeep(pch.Mergeability{ .source = .conflict, .squash = .conflict }, try readMergeability(target, io, allocator, id, patch)); 1235 try expectMergeabilityShortBytes(try target.core.latestMoment(), id); 1236 try std.testing.expectError(error.MergeConflict, pch.merge(repo_opts, io, allocator, repos_dir, target, input)); 1237 try std.testing.expectError(error.MergeConflict, pch.merge(repo_opts, io, allocator, repos_dir, target, squash_input)); 1238 try std.testing.expectEqual(events_before, try target.readRef(io, evt.events_ref)); 1239 try std.testing.expectEqual(conflicting_target, (try target.readRef(io, .{ .kind = .head, .name = "master" })).?); 1240 try std.testing.expectEqual(null, try target.readRef(io, .{ .kind = .none, .name = "MERGE_HEAD" })); 1241 1242 // deleting and restoring the target cannot reuse the conflict result 1243 { 1244 var detached = try target.switchDir(io, allocator, .{ .target = .{ .oid = base } }); 1245 defer detached.deinit(); 1246 } 1247 try target.removeBranch(io, .{ .name = "master" }); 1248 pch.refreshOpenMergeability(repo_opts, io, allocator, target, null, null); 1249 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, patch)); 1250 try expectMergeabilityShortBytes(try target.core.latestMoment(), id); 1251 try target.addBranch(io, .{ .name = "master" }); 1252 { 1253 var restored = try target.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "master" } } }); 1254 defer restored.deinit(); 1255 } 1256 pch.refreshOpenMergeability(repo_opts, io, allocator, target, null, null); 1257 try std.testing.expectEqualDeep(clean, try readMergeability(target, io, allocator, id, patch)); 1258 1259 // a missing fork disables merging without changing the accepted events 1260 const draft_path = try fork.forkPath(allocator, repos_dir, &std.fmt.bytesToHex(id.*, .lower)); 1261 defer allocator.free(draft_path); 1262 const away_path = try std.fmt.allocPrint(allocator, "{s}.away", .{draft_path}); 1263 defer allocator.free(away_path); 1264 { 1265 try std.Io.Dir.renameAbsolute(draft_path, away_path, io); 1266 defer std.Io.Dir.renameAbsolute(away_path, draft_path, io) catch {}; 1267 { 1268 const log_level = std.testing.log_level; 1269 std.testing.log_level = .err; 1270 defer std.testing.log_level = log_level; 1271 try std.testing.expectError(error.PatchDataUnavailable, pch.merge(repo_opts, io, allocator, repos_dir, target, input)); 1272 } 1273 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, patch)); 1274 try std.testing.expectEqual(events_before, try target.readRef(io, evt.events_ref)); 1275 } 1276 pch.refreshMergeability(repo_opts, io, allocator, target, id.*); 1277 try std.testing.expectEqualDeep(clean, try readMergeability(target, io, allocator, id, patch)); 1278 1279 // a changed revision is unknown even if its target has not moved 1280 var changed = patch; 1281 changed.revision.?.id[0] = if (changed.revision.?.id[0] == 'a') 'b' else 'a'; 1282 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, changed)); 1283 } 1284