Exemplo n.º 1
0
        public virtual void TestAddAdd()
        {
            Note add1   = NewNote("add1");
            Note add2   = NewNote("add2");
            Note result = merger.Merge(null, add1, add2, reader, inserter);

            NUnit.Framework.Assert.AreEqual(result, noteOn);
            // same note
            NUnit.Framework.Assert.AreEqual(result.GetData(), tr.Blob("add1add2"));
            result = merger.Merge(null, add2, add1, reader, inserter);
            NUnit.Framework.Assert.AreEqual(result, noteOn);
            // same note
            NUnit.Framework.Assert.AreEqual(result.GetData(), tr.Blob("add2add1"));
        }
Exemplo n.º 2
0
        public virtual void TestEditEdit()
        {
            Note edit1  = NewNote("edit1");
            Note edit2  = NewNote("edit2");
            Note result = merger.Merge(baseNote, edit1, edit2, reader, inserter);

            NUnit.Framework.Assert.AreEqual(result, noteOn);
            // same note
            NUnit.Framework.Assert.AreEqual(result.GetData(), tr.Blob("edit1edit2"));
            result = merger.Merge(baseNote, edit2, edit1, reader, inserter);
            NUnit.Framework.Assert.AreEqual(result, noteOn);
            // same note
            NUnit.Framework.Assert.AreEqual(result.GetData(), tr.Blob("edit2edit1"));
        }
        private TreeFormatter Build()
        {
            byte[]        nameBuf = new byte[Constants.OBJECT_ID_STRING_LENGTH];
            int           nameLen = Constants.OBJECT_ID_STRING_LENGTH - prefixLen;
            TreeFormatter fmt     = new TreeFormatter(TreeSize(nameLen));
            NonNoteEntry  e       = nonNotes;

            for (int i = 0; i < cnt; i++)
            {
                Note n = notes[i];
                n.CopyTo(nameBuf, 0);
                while (e != null && e.PathCompare(nameBuf, prefixLen, nameLen, FileMode.REGULAR_FILE
                                                  ) < 0)
                {
                    e.Format(fmt);
                    e = e.next;
                }
                fmt.Append(nameBuf, prefixLen, nameLen, FileMode.REGULAR_FILE, n.GetData());
            }
            for (; e != null; e = e.next)
            {
                e.Format(fmt);
            }
            return(fmt);
        }
Exemplo n.º 4
0
 private static string NoteData(Note n)
 {
     if (n != null)
     {
         return(n.GetData().Name);
     }
     return(string.Empty);
 }
Exemplo n.º 5
0
 private static bool SameContent(Note a, Note b)
 {
     if (a == null && b == null)
     {
         return(true);
     }
     return(a != null && b != null && AnyObjectId.Equals(a.GetData(), b.GetData()));
 }
Exemplo n.º 6
0
 private static string NoteData(Note n)
 {
     if (n != null)
     {
         return n.GetData().Name;
     }
     return string.Empty;
 }
Exemplo n.º 7
0
		/// <exception cref="System.IO.IOException"></exception>
		public virtual Note Merge(Note @base, Note ours, Note theirs, ObjectReader reader
			, ObjectInserter inserter)
		{
			if (ours == null)
			{
				return theirs;
			}
			if (theirs == null)
			{
				return ours;
			}
			if (ours.GetData().Equals(theirs.GetData()))
			{
				return ours;
			}
			ObjectLoader lo = reader.Open(ours.GetData());
			ObjectLoader lt = reader.Open(theirs.GetData());
			UnionInputStream union = new UnionInputStream(lo.OpenStream(), lt.OpenStream());
			ObjectId noteData = inserter.Insert(Constants.OBJ_BLOB, lo.GetSize() + lt.GetSize
				(), union);
			return new Note(ours, noteData);
		}
Exemplo n.º 8
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual Note Merge(Note @base, Note ours, Note theirs, ObjectReader reader
                                  , ObjectInserter inserter)
        {
            if (ours == null)
            {
                return(theirs);
            }
            if (theirs == null)
            {
                return(ours);
            }
            if (ours.GetData().Equals(theirs.GetData()))
            {
                return(ours);
            }
            ObjectLoader     lo       = reader.Open(ours.GetData());
            ObjectLoader     lt       = reader.Open(theirs.GetData());
            UnionInputStream union    = new UnionInputStream(lo.OpenStream(), lt.OpenStream());
            ObjectId         noteData = inserter.Insert(Constants.OBJ_BLOB, lo.GetSize() + lt.GetSize
                                                            (), union);

            return(new Note(ours, noteData));
        }
		private static string NoteData(Note n)
		{
			if (n != null)
			{
				return n.GetData().Name;
			}
			return string.Empty;
		}
Exemplo n.º 10
0
		private static bool SameContent(Note a, Note b)
		{
			if (a == null && b == null)
			{
				return true;
			}
			return a != null && b != null && AnyObjectId.Equals(a.GetData(), b.GetData());
		}