public virtual void TestLargeTreesWithConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap largeTree2 = CreateLargeNoteMap("note_1_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, largeTree1, largeTree2); NUnit.Framework.Assert.AreEqual(300, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59content_2_59"), result.Get(tr .Blob("note_1_59"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_10content_2_10"), result.Get(tr .Blob("note_1_10"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_99content_2_99"), result.Get(tr .Blob("note_1_99"))); }
public virtual void TestLargeTreesWithoutConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap map1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap map2 = CreateLargeNoteMap("note_2_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, map1, map2); NUnit.Framework.Assert.AreEqual(600, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59"), result.Get(tr.Blob("note_1_59" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_10"), result.Get(tr.Blob("note_2_10" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_99"), result.Get(tr.Blob("note_2_99" ))); }
public virtual void TestEditFlat() { RevBlob a = tr.Blob("a"); RevBlob b = tr.Blob("b"); RevBlob data1 = tr.Blob("data1"); RevBlob data2 = tr.Blob("data2"); RevCommit r = tr.Commit().Add(a.Name, data1).Add(b.Name, data2).Add(".gitignore", string.Empty).Add("zoo-animals.txt", b).Create(); // // // // // tr.ParseBody(r); NoteMap map = NoteMap.Read(reader, r); map.Set(a, data2); map.Set(b, null); map.Set(data1, b); map.Set(data2, null); NUnit.Framework.Assert.AreEqual(data2, map.Get(a)); NUnit.Framework.Assert.AreEqual(b, map.Get(data1)); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2"); MutableObjectId id = new MutableObjectId(); for (int p = 42; p > 0; p--) { id.SetByte(1, p); map.Set(id, data1); } for (int p_1 = 42; p_1 > 0; p_1--) { id.SetByte(1, p_1); NUnit.Framework.Assert.IsTrue(map.Contains(id), "contains " + id); } RevCommit n = CommitNoteMap(map); map = NoteMap.Read(reader, n); NUnit.Framework.Assert.AreEqual(data2, map.Get(a)); NUnit.Framework.Assert.AreEqual(b, map.Get(data1)); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2"); NUnit.Framework.Assert.AreEqual(b, TreeWalk.ForPath(reader, "zoo-animals.txt", n. Tree).GetObjectId(0)); }
public virtual void TestReadFlatTwoNotes() { RevBlob a = tr.Blob("a"); RevBlob b = tr.Blob("b"); RevBlob data1 = tr.Blob("data1"); RevBlob data2 = tr.Blob("data2"); RevCommit r = tr.Commit().Add(a.Name, data1).Add(b.Name, data2).Create(); // // // tr.ParseBody(r); NoteMap map = NoteMap.Read(reader, r); NUnit.Framework.Assert.IsNotNull(map, "have map"); NUnit.Framework.Assert.IsTrue(map.Contains(a), "has note for a"); NUnit.Framework.Assert.IsTrue(map.Contains(b), "has note for b"); NUnit.Framework.Assert.AreEqual(data1, map.Get(a)); NUnit.Framework.Assert.AreEqual(data2, map.Get(b)); NUnit.Framework.Assert.IsFalse(map.Contains(data1), "no note for data1"); NUnit.Framework.Assert.IsNull(map.Get(data1), "no note for data1"); }
public virtual void TestEditFanout2_38() { RevBlob a = tr.Blob("a"); RevBlob b = tr.Blob("b"); RevBlob data1 = tr.Blob("data1"); RevBlob data2 = tr.Blob("data2"); RevCommit r = tr.Commit().Add(Fanout(2, a.Name), data1).Add(Fanout(2, b.Name), data2 ).Add(".gitignore", string.Empty).Add("zoo-animals.txt", b).Create(); // // // // // tr.ParseBody(r); NoteMap map = NoteMap.Read(reader, r); map.Set(a, data2); map.Set(b, null); map.Set(data1, b); map.Set(data2, null); NUnit.Framework.Assert.AreEqual(data2, map.Get(a)); NUnit.Framework.Assert.AreEqual(b, map.Get(data1)); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2"); RevCommit n = CommitNoteMap(map); map.Set(a, null); map.Set(data1, null); NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a"); NUnit.Framework.Assert.IsFalse(map.Contains(data1), "no data1"); map = NoteMap.Read(reader, n); NUnit.Framework.Assert.AreEqual(data2, map.Get(a)); NUnit.Framework.Assert.AreEqual(b, map.Get(data1)); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2"); NUnit.Framework.Assert.AreEqual(b, TreeWalk.ForPath(reader, "zoo-animals.txt", n. Tree).GetObjectId(0)); }
public virtual void TestCreateFromEmpty() { RevBlob a = tr.Blob("a"); RevBlob b = tr.Blob("b"); RevBlob data1 = tr.Blob("data1"); RevBlob data2 = tr.Blob("data2"); NoteMap map = NoteMap.NewEmptyMap(); NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a"); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); map.Set(a, data1); map.Set(b, data2); NUnit.Framework.Assert.AreEqual(data1, map.Get(a)); NUnit.Framework.Assert.AreEqual(data2, map.Get(b)); map.Remove(a); map.Remove(b); NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a"); NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b"); map.Set(a, "data1", inserter); NUnit.Framework.Assert.AreEqual(data1, map.Get(a)); map.Set(a, null, inserter); NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a"); }
public virtual void TestFanoutAndLeafWitConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree_b1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); string noteBContent1 = noteBContent + "change"; largeTree_b1.Set(noteBId, tr.Blob(noteBContent1)); largeTree_b1.WriteTree(inserter); NoteMap result = merger.Merge(map_a, map_a_b, largeTree_b1); NUnit.Framework.Assert.AreEqual(301, CountNotes(result)); NUnit.Framework.Assert.AreEqual(tr.Blob(noteBContent + noteBContent1), result.Get (noteBId)); }