public void MergeFileDeletionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(a.Id, "newBranch", createNewBranch: true); var page = a.Applications[0].Pages[0]; var updateName = a.With(c => c.Remove(page, p => p.Fields, page.Fields[1])); container.Commit(updateName, signature, message); // B a = container.Checkout(a.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Deleted)); Assert.That(changes[0].Old.Id, Is.EqualTo(page.Fields[1].Id)); }
public void MergeFileAdditionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IServiceProvider serviceProvider, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(c => c.Add(sut.Applications[0].Pages[0], p => p.Fields, new Field(serviceProvider, UniqueId.CreateNew(), "new field", FieldContent.Default))); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Added)); Assert.That(changes[0].New.Name, Is.EqualTo("new field")); }
public void MergeTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(sut.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo(sut.Applications[0].Pages[0].Name)); Assert.That(changes[0].New.Name, Is.EqualTo(updateName.Name)); }
public void MergeSamePropertyConflict(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); var commitC = container.Commit(updateNameOther.Repository, signature, message); // C var merge = container.Merge(sut.Id, "newBranch"); var chunk = merge.ModifiedProperties.Single(); chunk.Resolve("merged name"); var mergeCommit = merge.Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo("yet again modified name")); Assert.That(changes[0].New.Name, Is.EqualTo("merged name")); }
public void MergeSamePropertyDetectsConflicts(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); container.Commit(updateNameOther.Repository, signature, message); // C Assert.Throws <RemainingConflictsException>(() => container.Merge(sut.Id, "newBranch").Apply(signature)); }
public void MergeTwoDifferentPropertiesWithMigrationChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IFixture fixture, Signature signature, string message) { // master: A-----D-----E---F // \ / / // \ ,---' / // \ / x / // newBranch: B---C---' (B contains a non-idempotent migration) // Arrange var a = container.AddRepository(sut, signature, message); // A // B, C a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updatedInstance = a.With(c => c.Add(a, r => r.Migrations, fixture.Create <DummyMigration>())); var b = container.Commit(updatedInstance, signature, message); // B Assert.That(b.Migrations.Count, Is.GreaterThan(0)); var updateName = b.With(b.Applications[1].Pages[1], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // C // D a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); container.Commit(updateDescription.Repository, signature, message); // D // E var mergeStep1 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep1.IsPartialMerge, Is.True); mergeStep1.Apply(signature); // E // F var mergeStep2 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep2.IsPartialMerge, Is.False); mergeStep2.Apply(signature); // F }
static void CreateConflictingChange(BlobRepository sut, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message) { // master: A---B // \ (B & C change same value) // newBranch: C -> A---B---C var a = container.AddRepository(sut, signature, message); // A var updateName = a.With(a, r => r.Blob, new StringBlob("x\nb\nc")); container.Commit(updateName.Repository, signature, message); // B container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var updates = a.With(a, r => r.Blob, new StringBlob("z\nb\nd")); container.Commit(updates, signature, message); }
static IObjectRepositoryCherryPick CreateConflictingCherryPick(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ (B & C change same property) // newBranch: C -> A---C---B var a = container.AddRepository(sut, signature, message); // A var b = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Name, "foo").Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); container.Commit( a.With(c => c .Update(a.Applications[0].Pages[0], p => p.Name, "bar") .Update(a.Applications[0].Pages[0], p => p.Description, "bar") .Update(a.Applications[0].Pages[0].Fields[0], f => f.Name, "bar")), signature, message); return(container.CherryPick(sut.Id, b.CommitId)); }
public void CherryPickChildAddition(IServiceProvider serviceProvider, ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B---C // \ // newBranch: D -> A---D---C // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var b = container.Commit( a.With(a.Applications[0], app => app.Name, "unpicked modified name").Repository, signature, message); // B var page = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>()); var c = container.Commit( b.With(comp => comp.Add(b.Applications[0], app => app.Pages, page)).Repository, signature, message); // C a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~2"); var d = container.Commit( a.With(a.Applications[0], app => app.Name, "modified name").Repository, signature, message); // D var cherryPick = container.CherryPick(sut.Id, c.CommitId); var repository = container.Repositories.Single(); // Assert Assert.That(cherryPick.Status, Is.EqualTo(CherryPickStatus.CherryPicked)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(commit => commit.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits, Has.Count.EqualTo(3)); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(d.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages, Has.Count.EqualTo(a.Applications[0].Pages.Count + 1)); }
public void RebaseFailsWhenUpstreamBranchContainsMigrations(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, DummyMigration migration) { // master: A---B (B contains a migration) // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act container.Commit( a.With(c => c.Add(a, r => r.Migrations, migration)).Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "modified description").Repository, signature, message); // C Assert.Throws <NotSupportedException>(() => container.Rebase(sut.Id, "master")); }
public void CherryPickTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B---C // \ // newBranch: D -> A---D---C // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var b = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "unpicked modified description").Repository, signature, message); // B var c = container.Commit( b.With(b.Applications[0].Pages[0], p => p.Name, "modified name").Repository, signature, message); // C a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~2"); var d = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "modified description").Repository, signature, message); // D var cherryPick = container.CherryPick(sut.Id, c.CommitId); var repository = container.Repositories.Single(); // Assert Assert.That(cherryPick.Status, Is.EqualTo(CherryPickStatus.CherryPicked)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(commit => commit.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(d.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Pages[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages[0].Description, Is.EqualTo("modified description")); }
public void RebaseChildAddition(IServiceProvider serviceProvider, ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var updateName = a.With(a.Applications[0], app => app.Name, "modified name"); var b = container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var page = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>()); var addPage = a.With(c => c.Add(a.Applications[0], app => app.Pages, page)); container.Commit(addPage.Repository, signature, message); // C var rebase = container.Rebase(sut.Id, "master"); var repository = container.Repositories.Single(); // Assert Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete)); Assert.That(rebase.TotalStepCount, Is.EqualTo(1)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits, Has.Count.EqualTo(3)); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(b.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages, Has.Count.EqualTo(a.Applications[0].Pages.Count + 1)); }
public void RebaseTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); var b = container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); container.Commit(updateDescription.Repository, signature, message); // C var rebase = container.Rebase(sut.Id, "master"); var repository = container.Repositories.Single(); // Assert Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete)); Assert.That(rebase.TotalStepCount, Is.EqualTo(1)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(b.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Pages[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages[0].Description, Is.EqualTo("modified description")); }