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); }
/// <exception cref="System.IO.IOException"></exception> private ObjectId Write(NonNoteEntry list) { LeafBucket b = new LeafBucket(0); b.nonNotes = list; return(b.WriteTree(inserter)); }
/// <exception cref="System.IO.IOException"></exception> private NonNoteEntry MergeNonNotes(NonNoteEntry baseList, NonNoteEntry oursList, NonNoteEntry theirsList) { if (baseList == null && oursList == null && theirsList == null) { return(null); } ObjectId baseId = Write(baseList); ObjectId oursId = Write(oursList); ObjectId theirsId = Write(theirsList); inserter.Flush(); Merger m = nonNotesMergeStrategy.NewMerger(db, true); if (m is ThreeWayMerger) { ((ThreeWayMerger)m).SetBase(baseId); } if (!m.Merge(oursId, theirsId)) { throw new NotesMergeConflictException(baseList, oursList, theirsList); } ObjectId resultTreeId = m.GetResultTreeId(); AbbreviatedObjectId none = AbbreviatedObjectId.FromString(string.Empty); return(NoteParser.Parse(none, resultTreeId, reader).nonNotes); }
private int TreeSize(int nameLen) { int sz = cnt * TreeFormatter.EntrySize(FileMode.REGULAR_FILE, nameLen); for (NonNoteEntry e = nonNotes; e != null; e = e.next) { sz += e.TreeEntrySize(); } return(sz); }
private int TreeSize() { int sz = cnt * TreeFormatter.EntrySize(FileMode.TREE, 2); for (NonNoteEntry e = nonNotes; e != null; e = e.next) { sz += e.TreeEntrySize(); } return(sz); }
private static int CountNonNotes(NoteMap map) { int c = 0; NonNoteEntry nonNotes = map.GetRoot().nonNotes; while (nonNotes != null) { c++; nonNotes = nonNotes.next; } return(c); }
private void StoreNonNote() { ObjectId id = EntryObjectId; FileMode fileMode = EntryFileMode; byte[] name = new byte[NameLength]; GetName(name, 0); NonNoteEntry ent = new NonNoteEntry(name, fileMode, id); if (firstNonNote == null) { firstNonNote = ent; } if (lastNonNote != null) { lastNonNote.next = ent; } lastNonNote = ent; }
/// <exception cref="System.IO.IOException"></exception> private TreeFormatter Build(bool insert, ObjectInserter inserter) { byte[] nameBuf = new byte[2]; TreeFormatter fmt = new TreeFormatter(TreeSize()); NonNoteEntry e = nonNotes; for (int cell = 0; cell < 256; cell++) { NoteBucket b = table[cell]; if (b == null) { continue; } nameBuf[0] = hexchar[(int)(((uint)cell) >> 4)]; nameBuf[1] = hexchar[cell & unchecked ((int)(0x0f))]; while (e != null && e.PathCompare(nameBuf, 0, 2, FileMode.TREE) < 0) { e.Format(fmt); e = e.next; } ObjectId id; if (insert) { id = b.WriteTree(inserter); } else { id = b.GetTreeId(); } fmt.Append(nameBuf, 0, 2, FileMode.TREE, id); } for (; e != null; e = e.next) { e.Format(fmt); } return(fmt); }
/// <summary> /// Constructs a NotesMergeConflictException for the specified base, ours and /// theirs versions of the root note tree. /// </summary> /// <remarks> /// Constructs a NotesMergeConflictException for the specified base, ours and /// theirs versions of the root note tree. /// </remarks> /// <param name="base">version of the root note tree</param> /// <param name="ours">version of the root note tree</param> /// <param name="theirs">version of the root note tree</param> internal NotesMergeConflictException(NonNoteEntry @base, NonNoteEntry ours, NonNoteEntry theirs) : base(MessageFormat.Format(JGitText.Get().mergeConflictOnNonNoteEntries , Name(@base), Name(ours), Name(theirs))) { }
private static string Name(NonNoteEntry e) { return e != null ? e.Name : string.Empty; }
private static string Name(NonNoteEntry e) { return(e != null ? e.Name : string.Empty); }
/// <exception cref="System.IO.IOException"></exception> private ObjectId Write(NonNoteEntry list) { LeafBucket b = new LeafBucket(0); b.nonNotes = list; return b.WriteTree(inserter); }
/// <exception cref="System.IO.IOException"></exception> private NonNoteEntry MergeNonNotes(NonNoteEntry baseList, NonNoteEntry oursList, NonNoteEntry theirsList) { if (baseList == null && oursList == null && theirsList == null) { return null; } ObjectId baseId = Write(baseList); ObjectId oursId = Write(oursList); ObjectId theirsId = Write(theirsList); inserter.Flush(); Merger m = nonNotesMergeStrategy.NewMerger(db, true); if (m is ThreeWayMerger) { ((ThreeWayMerger)m).SetBase(baseId); } if (!m.Merge(oursId, theirsId)) { throw new NotesMergeConflictException(baseList, oursList, theirsList); } ObjectId resultTreeId = m.GetResultTreeId(); AbbreviatedObjectId none = AbbreviatedObjectId.FromString(string.Empty); return NoteParser.Parse(none, resultTreeId, reader).nonNotes; }