/// <exception cref="System.Exception"></exception> public virtual void TestIteratorFullyFannedOut() { RevBlob a = tr.Blob("a"); RevBlob b = tr.Blob("b"); RevBlob data1 = tr.Blob("data1"); RevBlob data2 = tr.Blob("data2"); RevBlob nonNote = tr.Blob("non note"); RevCommit r = tr.Commit().Add(Fanout(38, a.Name), data1).Add(Fanout(38, b.Name), data2).Add("nonNote", nonNote).Create(); // // // // tr.ParseBody(r); Iterator it = NoteMap.Read(reader, r).Iterator(); NUnit.Framework.Assert.AreEqual(2, Count(it)); }
public virtual void TestLeafSplitsWhenFull() { RevBlob data1 = tr.Blob("data1"); MutableObjectId idBuf = new MutableObjectId(); RevCommit r = tr.Commit().Add(data1.Name, data1).Create(); // // tr.ParseBody(r); NoteMap map = NoteMap.Read(reader, r); for (int i = 0; i < 254; i++) { idBuf.SetByte(Constants.OBJECT_ID_LENGTH - 1, i); map.Set(idBuf, data1); } RevCommit n = CommitNoteMap(map); TreeWalk tw = new TreeWalk(reader); tw.Reset(n.Tree); while (tw.Next()) { NUnit.Framework.Assert.IsFalse(tw.IsSubtree, "no fan-out subtree"); } for (int i_1 = 254; i_1 < 256; i_1++) { idBuf.SetByte(Constants.OBJECT_ID_LENGTH - 1, i_1); map.Set(idBuf, data1); } idBuf.SetByte(Constants.OBJECT_ID_LENGTH - 2, 1); map.Set(idBuf, data1); n = CommitNoteMap(map); // The 00 bucket is fully split. string path = Fanout(38, idBuf.Name); tw = TreeWalk.ForPath(reader, path, n.Tree); NUnit.Framework.Assert.IsNotNull(tw, "has " + path); // The other bucket is not. path = Fanout(2, data1.Name); tw = TreeWalk.ForPath(reader, path, n.Tree); NUnit.Framework.Assert.IsNotNull(tw, "has " + path); }
public virtual void TestEditDifferentNotes() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NoteMap map_a1_b = NoteMap.Read(reader, sampleTree_a_b); string noteAContent1 = noteAContent + "change"; RevBlob noteABlob1 = tr.Blob(noteAContent1); map_a1_b.Set(noteAId, noteABlob1); map_a1_b.WriteTree(inserter); NoteMap map_a_b1 = NoteMap.Read(reader, sampleTree_a_b); string noteBContent1 = noteBContent + "change"; RevBlob noteBBlob1 = tr.Blob(noteBContent1); map_a_b1.Set(noteBId, noteBBlob1); map_a_b1.WriteTree(inserter); result = merger.Merge(map_a_b, map_a1_b, map_a_b1); NUnit.Framework.Assert.AreEqual(2, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob1, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob1, result.Get(noteBId)); }
public virtual void TestEditSameNoteDifferentContent() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap result; NoteMap map_a1 = NoteMap.Read(reader, sampleTree_a); string noteAContent1 = noteAContent + "change1"; RevBlob noteABlob1 = tr.Blob(noteAContent1); map_a1.Set(noteAId, noteABlob1); map_a1.WriteTree(inserter); NoteMap map_a2 = NoteMap.Read(reader, sampleTree_a); string noteAContent2 = noteAContent + "change2"; RevBlob noteABlob2 = tr.Blob(noteAContent2); map_a2.Set(noteAId, noteABlob2); map_a2.WriteTree(inserter); result = merger.Merge(map_a, map_a1, map_a2); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(tr.Blob(noteAContent1 + noteAContent2), result.Get (noteAId)); }
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 override void SetUp() { base.SetUp(); tr = new TestRepository <Repository>(db); reader = db.NewObjectReader(); inserter = db.NewObjectInserter(); noRoot = NoteMap.NewMap(null, reader); empty = NoteMap.NewEmptyMap(); noteAId = tr.Blob("a"); noteAContent = "noteAContent"; noteABlob = tr.Blob(noteAContent); sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create(); tr.ParseBody(sampleTree_a); map_a = NoteMap.Read(reader, sampleTree_a); noteBId = tr.Blob("b"); noteBContent = "noteBContent"; noteBBlob = tr.Blob(noteBContent); sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob ).Create(); tr.ParseBody(sampleTree_a_b); map_a_b = NoteMap.Read(reader, sampleTree_a_b); }
public virtual void TestWriteUnchangedFlat() { 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", string.Empty).Create(); // // // // // tr.ParseBody(r); NoteMap map = NoteMap.Read(reader, r); NUnit.Framework.Assert.IsTrue(map.Contains(a), "has note for a"); NUnit.Framework.Assert.IsTrue(map.Contains(b), "has note for b"); RevCommit n = CommitNoteMap(map); NUnit.Framework.Assert.AreNotSame(r, n, "is new commit"); NUnit.Framework.Assert.AreSame(r.Tree, n.Tree, "same tree"); }
public virtual void TestNonNotesWithoutNonNoteConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, MergeStrategy.RESOLVE); RevCommit treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt" , tr.Blob("content of a.txt")).Create(); // this is a note // this is a non-note tr.ParseBody(treeWithNonNotes); NoteMap @base = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("b.txt", tr.Blob("content of b.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap ours = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("c.txt", tr.Blob("content of c.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap theirs = NoteMap.Read(reader, treeWithNonNotes); NoteMap result = merger.Merge(@base, ours, theirs); NUnit.Framework.Assert.AreEqual(3, CountNonNotes(result)); }