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"); }
/// <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; }
private static InMemoryNoteBucket AddIfNotNull(InMemoryNoteBucket result, Note note ) { if (note != null) { return result.Append(note); } else { return result; } }
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()); }
private static bool SameNote(Note a, Note b) { if (a == null && b == null) { return true; } return a != null && b != null && AnyObjectId.Equals(a, b); }
private static Note SameNoteOrNull(Note min, Note other) { return SameNote(min, other) ? other : null; }
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; }
internal virtual void ParseOneEntry(AnyObjectId noteOn, AnyObjectId noteData) { GrowIfFull(); notes[cnt++] = new Note(noteOn, noteData.Copy()); }
internal abstract NGit.Notes.InMemoryNoteBucket Append(Note note);