예제 #1
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private InMemoryNoteBucket MergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket
                                                   ob, LeafBucket tb)
        {
            bb = NotNullOrEmpty(bb);
            ob = NotNullOrEmpty(ob);
            tb = NotNullOrEmpty(tb);
            InMemoryNoteBucket result = new LeafBucket(treeDepth * 2);
            int bi = 0;
            int oi = 0;
            int ti = 0;

            while (bi < bb.Size() || oi < ob.Size() || ti < tb.Size())
            {
                Note b   = Get(bb, bi);
                Note o   = Get(ob, oi);
                Note t   = Get(tb, ti);
                Note min = Min(b, o, t);
                b = SameNoteOrNull(min, b);
                o = SameNoteOrNull(min, o);
                t = SameNoteOrNull(min, t);
                if (SameContent(o, t))
                {
                    result = AddIfNotNull(result, o);
                }
                else
                {
                    if (SameContent(b, o))
                    {
                        result = AddIfNotNull(result, t);
                    }
                    else
                    {
                        if (SameContent(b, t))
                        {
                            result = AddIfNotNull(result, o);
                        }
                        else
                        {
                            result = AddIfNotNull(result, noteMerger.Merge(b, o, t, reader, inserter));
                        }
                    }
                }
                if (b != null)
                {
                    bi++;
                }
                if (o != null)
                {
                    oi++;
                }
                if (t != null)
                {
                    ti++;
                }
            }
            return(result);
        }
예제 #2
0
 private static Note Get(LeafBucket b, int i)
 {
     return(i < b.Size() ? b.Get(i) : null);
 }