/// <exception cref="System.IO.IOException"></exception>
 private RevCommit CommitNoteMap(NoteMap map)
 {
     tr.Tick(600);
     NGit.CommitBuilder builder = new NGit.CommitBuilder();
     builder.TreeId = map.WriteTree(inserter);
     tr.SetAuthorAndCommitter(builder);
     return(tr.GetRevWalk().ParseCommit(inserter.Insert(builder)));
 }
Exemple #2
0
        public virtual void TestDeleteDifferentNotes()
        {
            NoteMapMerger merger = new NoteMapMerger(db, null, null);
            NoteMap       map_b  = NoteMap.Read(reader, sampleTree_a_b);

            map_b.Set(noteAId, null);
            // delete note a
            map_b.WriteTree(inserter);
            NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a_b, map_a, map_b)
                                                          ));
        }
Exemple #3
0
        /// <exception cref="System.Exception"></exception>
        private NoteMap CreateLargeNoteMap(string noteNamePrefix, string noteContentPrefix
                                           , int notesCount, int firstIndex)
        {
            NoteMap result = NoteMap.NewEmptyMap();

            for (int i = 0; i < notesCount; i++)
            {
                result.Set(tr.Blob(noteNamePrefix + (firstIndex + i)), tr.Blob(noteContentPrefix
                                                                               + (firstIndex + i)));
            }
            result.WriteTree(inserter);
            return(result);
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        public virtual void TestEditDeleteConflict()
        {
            NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null);
            NoteMap       result;
            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_a_b1, map_a);
            NUnit.Framework.Assert.AreEqual(2, CountNotes(result));
            NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId));
            NUnit.Framework.Assert.AreEqual(noteBBlob1, result.Get(noteBId));
        }
Exemple #6
0
        public virtual void TestAddDifferentNotes()
        {
            NoteMapMerger merger = new NoteMapMerger(db, null, null);
            NoteMap       result;
            NoteMap       map_a_c   = NoteMap.Read(reader, sampleTree_a);
            RevBlob       noteCId   = tr.Blob("c");
            RevBlob       noteCBlob = tr.Blob("noteCContent");

            map_a_c.Set(noteCId, noteCBlob);
            map_a_c.WriteTree(inserter);
            result = merger.Merge(map_a, map_a_b, map_a_c);
            NUnit.Framework.Assert.AreEqual(3, CountNotes(result));
            NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId));
            NUnit.Framework.Assert.AreEqual(noteBBlob, result.Get(noteBId));
            NUnit.Framework.Assert.AreEqual(noteCBlob, result.Get(noteCId));
        }
Exemple #7
0
        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));
        }
Exemple #8
0
		/// <exception cref="System.IO.IOException"></exception>
		private RevCommit CommitNoteMap(NoteMap map)
		{
			tr.Tick(600);
			NGit.CommitBuilder builder = new NGit.CommitBuilder();
			builder.TreeId = map.WriteTree(inserter);
			tr.SetAuthorAndCommitter(builder);
			return tr.GetRevWalk().ParseCommit(inserter.Insert(builder));
		}