feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) #26
No files matched your search
@@ -329,7 +329,7 @@ public sealed record ProjectSettings
|
||||
public const int BaseVersion = 1;
|
||||
|
||||
/// <summary>Layout of a project edited as JSON (<see cref="MoveFramePositions"/>): indented like <see cref="ToJson"/>, with LF line ends on every OS.</summary>
|
||||
private static readonly JsonSerializerOptions IndentedJson = new() { WriteIndented = true, NewLine = "\n" };
|
||||
internal static readonly JsonSerializerOptions IndentedJson = new() { WriteIndented = true, NewLine = "\n" };
|
||||
|
||||
/// <summary>Member names as a project edited as JSON reads them (an older or hand-written file may use any casing).</summary>
|
||||
private static readonly JsonNodeOptions CaseInsensitive = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
@@ -1479,7 +1479,8 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
if (project.Versions().FirstOrDefault(v => v.Id == restoredId) is not { } restored) return true;
|
||||
var then = ProjectContent.Rebind(restored.SettingsJson, photos);
|
||||
var before = parent is null ? ProjectContent.ToPortable(new ProjectSettings(), photos) : ProjectContent.Rebind(parent.SettingsJson, photos);
|
||||
if (then == before) return false;
|
||||
// The same choices are no different, whatever line ends either was stored with (a CRLF version of an older Windows build).
|
||||
if (ProjectContent.SameChoices(then, before, photos)) return false;
|
||||
var now = ProjectContent.Rebind(portable, photos);
|
||||
var merge = ProjectMerge.MergeWithConflicts(ProjectMerge.Read(before), ProjectMerge.Read(now), ProjectMerge.Read(then));
|
||||
return merge.Conflicts.Count == 0 && ProjectContent.Canonical(merge.Merged.ToJson()) == ProjectContent.Canonical(now);
|
||||
|
||||
@@ -351,6 +351,9 @@ public sealed class ProjectContentTests
|
||||
var frames = Frames(Photo(1), Photo(2), Photo(3));
|
||||
var lf = ProjectContent.ToPortable(Positions([1], 2, 0), frames);
|
||||
var crlf = lf.Replace("\n", "\r\n", StringComparison.Ordinal);
|
||||
// Every writer of project text names LF itself: on Linux Environment.NewLine is LF already, so only these fail there.
|
||||
Assert.Equal("\n", ProjectJson.Default.Options.NewLine);
|
||||
Assert.Equal("\n", ProjectSettings.IndentedJson.NewLine);
|
||||
Assert.False(lf.Contains('\r', StringComparison.Ordinal), "portable");
|
||||
Assert.False(new ProjectSettings().ToJson().Contains('\r', StringComparison.Ordinal), "ToJson");
|
||||
Assert.Equal(lf, ProjectContent.Canonical(crlf));
|
||||
|
||||
@@ -142,6 +142,34 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co
|
||||
Assert.Equal(foreign.Id, (await fx.Home.HeadAsync(id, fx.Ct)).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARestoreOfAVersionTheBaseHoldsWithOtherLineEndsIsNoRestore()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var projects = fx.Archive.Service.Projects;
|
||||
var main = await projects.MainAsync(fx.Sequence.Id, fx.Ct);
|
||||
var choices = new ProjectSettings { ExcludedFrames = [1], HeroFrame = 3 };
|
||||
// A version an older build stored on the other OS, then the same choices as this build writes them (the base).
|
||||
var foreign = ProjectServiceTests.Foreign(ProjectServiceTests.Draft(await projects.HeadAsync(main.Id, fx.Ct), choices, fx.Frames));
|
||||
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, foreign, fx.Ct)).Outcome);
|
||||
var same = ProjectServiceTests.Draft(foreign, choices, fx.Frames);
|
||||
Assert.NotEqual(foreign.SettingsJson, same.SettingsJson);
|
||||
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, same, fx.Ct)).Outcome);
|
||||
|
||||
var (_, sync) = fx.Workspace();
|
||||
var project = await fx.CheckoutAsync(sync);
|
||||
var id = project.ProjectId;
|
||||
Assert.Equal(same.Id, project.ReadBundle().Workspace!.Base!.VersionId);
|
||||
// The foreign version restored before a pull moved the base onto the same choices: the restore stays recorded.
|
||||
await sync.RestoreAsync(id, foreign.Id, fx.Home, fx.Ct);
|
||||
project.WriteSync(project.ReadSync() with { RestoredFrom = foreign.Id });
|
||||
|
||||
// Edited further and saved: the parent already holds the restored version, so the new version is a plain one.
|
||||
await EditAsync(sync, id, s => s with { Exposure = s.Exposure with { ExposureOffsetEv = 0.4 } }, fx.Ct);
|
||||
var next = Assert.NotNull(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
Assert.Equal((ProjectVersionKind.Commit, (Guid?)null), (next.Kind, next.RestoredFrom));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABaseNamingAPhotoByItsHashReadsAsTheWorkingStateOnMediaThatHaveNotLearntIt()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user