public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
			merger = new DefaultNoteMerger();
			noteOn = tr.Blob("a");
			baseNote = NewNote("data");
		}
示例#2
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 NoteOn(Note @base, Note ours, Note theirs)
		{
			if (@base != null)
			{
				return @base.Name;
			}
			if (ours != null)
			{
				return ours.Name;
			}
			return theirs.Name;
		}
		/// <summary>
		/// Construct a NotesMergeConflictException for the specified base, ours and
		/// theirs note versions.
		/// </summary>
		/// <remarks>
		/// Construct a NotesMergeConflictException for the specified base, ours and
		/// theirs note versions.
		/// </remarks>
		/// <param name="base">note version</param>
		/// <param name="ours">note version</param>
		/// <param name="theirs">note version</param>
		public NotesMergeConflictException(Note @base, Note ours, Note theirs) : base(MessageFormat
			.Format(JGitText.Get().mergeConflictOnNotes, NoteOn(@base, ours, theirs), NoteData
			(@base), NoteData(ours), NoteData(theirs)))
		{
		}
		private static string NoteData(Note n)
		{
			if (n != null)
			{
				return n.GetData().Name;
			}
			return string.Empty;
		}
示例#6
0
		private static InMemoryNoteBucket AddIfNotNull(InMemoryNoteBucket result, Note note
			)
		{
			if (note != null)
			{
				return result.Append(note);
			}
			else
			{
				return result;
			}
		}
示例#7
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());
		}
示例#8
0
		private static bool SameNote(Note a, Note b)
		{
			if (a == null && b == null)
			{
				return true;
			}
			return a != null && b != null && AnyObjectId.Equals(a, b);
		}
示例#9
0
		private static Note SameNoteOrNull(Note min, Note other)
		{
			return SameNote(min, other) ? other : null;
		}
示例#10
0
		private static Note Min(Note b, Note o, Note t)
		{
			Note min = b;
			if (min == null || (o != null && o.CompareTo(min) < 0))
			{
				min = o;
			}
			if (min == null || (t != null && t.CompareTo(min) < 0))
			{
				min = t;
			}
			return min;
		}
示例#11
0
 internal virtual void ParseOneEntry(AnyObjectId noteOn, AnyObjectId noteData)
 {
     GrowIfFull();
     notes[cnt++] = new Note(noteOn, noteData.Copy());
 }
示例#12
0
		internal abstract NGit.Notes.InMemoryNoteBucket Append(Note note);
示例#13
0
 /// <summary>
 /// Construct a NotesMergeConflictException for the specified base, ours and
 /// theirs note versions.
 /// </summary>
 /// <remarks>
 /// Construct a NotesMergeConflictException for the specified base, ours and
 /// theirs note versions.
 /// </remarks>
 /// <param name="base">note version</param>
 /// <param name="ours">note version</param>
 /// <param name="theirs">note version</param>
 public NotesMergeConflictException(Note @base, Note ours, Note theirs) : base(MessageFormat
                                                                               .Format(JGitText.Get().mergeConflictOnNotes, NoteOn(@base, ours, theirs), NoteData
                                                                                           (@base), NoteData(ours), NoteData(theirs)))
 {
 }