Updates a DirCache by adding individual DirCacheEntrys. A builder always starts from a clean slate and appends in every single DirCacheEntry which the final updated index must have to reflect its new content. For maximum performance applications should add entries in path name order. Adding entries out of order is permitted, however a final sorting pass will be implicitly performed during finish() to correct any out-of-order entries. Duplicate detection is also delayed until the sorting is complete.
상속: GitSharp.Core.DirectoryCache.BaseDirCacheEditor
 /// <summary>
 /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
 /// <para/>
 /// The iterator implementation may copy part of the cache's data during
 /// construction, so the cache must be Read in prior to creating the
 /// iterator.
 /// </summary>
 /// <param name="builder">
 /// The cache builder for the cache to walk. The cache must be
 /// already loaded into memory.
 /// </param>
 public DirCacheBuildIterator(DirCacheBuilder builder)
     : base(builder.getDirCache())
 {
     if (builder == null)
     {
         throw new System.ArgumentNullException("builder");
     }
     _builder = builder;
 }
        /// <summary>
        /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
        /// <para/>
        /// The iterator implementation may copy part of the cache's data during
        /// construction, so the cache must be Read in prior to creating the
        /// iterator.
        /// </summary>
        /// <param name="parentIterator">The parent iterator</param>
        /// <param name="cacheTree">The cache tree</param>
        DirCacheBuildIterator(DirCacheBuildIterator parentIterator, DirCacheTree cacheTree)
            : base(parentIterator, cacheTree)
        {
            if (parentIterator == null)
            {
                throw new System.ArgumentNullException("parentIterator");
            }

            _builder = parentIterator._builder;
        }
예제 #3
0
 /// <summary>
 /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
 /// <para/>
 /// The iterator implementation may copy part of the cache's data during
 /// construction, so the cache must be Read in prior to creating the
 /// iterator.
 /// </summary>
 /// <param name="builder">
 /// The cache builder for the cache to walk. The cache must be
 /// already loaded into memory.
 /// </param>
 public DirCacheBuildIterator(DirCacheBuilder builder)
     : base(builder.getDirCache())
 {
     _builder = builder;
 }
예제 #4
0
 /// <summary>
 /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
 /// <para/>
 /// The iterator implementation may copy part of the cache's data during
 /// construction, so the cache must be Read in prior to creating the
 /// iterator.
 /// </summary>
 /// <param name="parentIterator">The parent iterator</param>
 /// <param name="cacheTree">The cache tree</param>
 DirCacheBuildIterator(DirCacheBuildIterator parentIterator, DirCacheTree cacheTree)
     : base(parentIterator, cacheTree)
 {
     _builder = parentIterator._builder;
 }
            protected override bool MergeImpl()
            {
                _tw.reset();
                _tw.addTree(MergeBase());
                _tw.addTree(SourceTrees[0]);
                _tw.addTree(SourceTrees[1]);

                bool hasConflict = false;

                _builder = _cache.builder();
                while (_tw.next())
                {
                    int modeO = _tw.getRawMode(Ours);
                    int modeT = _tw.getRawMode(Theirs);
                    if (modeO == modeT && _tw.idEqual(Ours, Theirs))
                    {
                        Add(Ours, DirCacheEntry.STAGE_0);
                        continue;
                    }

                    int modeB = _tw.getRawMode(Base);
                    if (modeB == modeO && _tw.idEqual(Base, Ours))
                        Add(Theirs, DirCacheEntry.STAGE_0);
                    else if (modeB == modeT && _tw.idEqual(Base, Theirs))
                        Add(Ours, DirCacheEntry.STAGE_0);
                    else if (_tw.isSubtree())
                    {
                        if (NonTree(modeB))
                        {
                            Add(Base, DirCacheEntry.STAGE_1);
                            hasConflict = true;
                        }
                        if (NonTree(modeO))
                        {
                            Add(Ours, DirCacheEntry.STAGE_2);
                            hasConflict = true;
                        }
                        if (NonTree(modeT))
                        {
                            Add(Theirs, DirCacheEntry.STAGE_3);
                            hasConflict = true;
                        }
                        _tw.enterSubtree();
                    }
                    else
                    {
                        Add(Base, DirCacheEntry.STAGE_1);
                        Add(Ours, DirCacheEntry.STAGE_2);
                        Add(Theirs, DirCacheEntry.STAGE_3);
                        hasConflict = true;
                    }
                }
                _builder.finish();
                _builder = null;

                if (hasConflict)
                    return false;
                try
                {
                    _resultTree = _cache.writeTree(GetObjectWriter());
                    return true;
                }
                catch (UnmergedPathException)
                {
                    _resultTree = null;
                    return false;
                }
            }
예제 #6
0
		/// <summary>
		/// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
		/// <para/>
		/// The iterator implementation may copy part of the cache's data during
		/// construction, so the cache must be Read in prior to creating the
		/// iterator.
		/// </summary>
		/// <param name="builder">
		/// The cache builder for the cache to walk. The cache must be
		/// already loaded into memory.
		/// </param>
        public DirCacheBuildIterator(DirCacheBuilder builder)
            : base(builder.getDirCache())
        {
			if ( builder == null)
			{
				throw new System.ArgumentNullException("builder");
			}
            _builder = builder;
        }
예제 #7
0
		/// <summary>
		/// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
		/// <para/>
		/// The iterator implementation may copy part of the cache's data during
		/// construction, so the cache must be Read in prior to creating the
		/// iterator.
		/// </summary>
		/// <param name="parentIterator">The parent iterator</param>
		/// <param name="cacheTree">The cache tree</param>
        DirCacheBuildIterator(DirCacheBuildIterator parentIterator, DirCacheTree cacheTree)
            : base(parentIterator, cacheTree)
        {
			if (parentIterator == null)
				throw new System.ArgumentNullException ("parentIterator");
			
            _builder = parentIterator._builder;
        }
예제 #8
0
 /// <summary>
 /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
 /// <para/>
 /// The iterator implementation may copy part of the cache's data during
 /// construction, so the cache must be Read in prior to creating the
 /// iterator.
 /// </summary>
 /// <param name="builder">
 /// The cache builder for the cache to walk. The cache must be
 /// already loaded into memory.
 /// </param>
 public DirCacheBuildIterator(DirCacheBuilder builder)
     : base(builder.getDirCache())
 {
     _builder = builder;
 }
예제 #9
0
 /// <summary>
 /// Create a new iterator for an already loaded <see cref="DirCache"/> instance.
 /// <para/>
 /// The iterator implementation may copy part of the cache's data during
 /// construction, so the cache must be Read in prior to creating the
 /// iterator.
 /// </summary>
 /// <param name="parentIterator">The parent iterator</param>
 /// <param name="cacheTree">The cache tree</param>
 DirCacheBuildIterator(DirCacheBuildIterator parentIterator, DirCacheTree cacheTree)
     : base(parentIterator, cacheTree)
 {
     _builder = parentIterator._builder;
 }