コード例 #1
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="NGit.Errors.CorruptObjectException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private void UpdateFollowFilter(ObjectId[] trees)
        {
            TreeWalk     tw        = pathFilter;
            FollowFilter oldFilter = (FollowFilter)tw.Filter;

            tw.Filter = TreeFilter.ANY_DIFF;
            tw.Reset(trees);
            IList <DiffEntry> files = DiffEntry.Scan(tw);
            RenameDetector    rd    = new RenameDetector(repository);

            rd.AddAll(files);
            files = rd.Compute();
            TreeFilter newFilter = oldFilter;

            foreach (DiffEntry ent in files)
            {
                if (IsRename(ent) && ent.GetNewPath().Equals(oldFilter.GetPath()))
                {
                    newFilter = FollowFilter.Create(ent.GetOldPath());
                    RenameCallback callback = oldFilter.GetRenameCallback();
                    if (callback != null)
                    {
                        callback.Renamed(ent);
                        // forward the callback to the new follow filter
                        ((FollowFilter)newFilter).SetRenameCallback(callback);
                    }
                    break;
                }
            }
            tw.Filter = newFilter;
        }
コード例 #2
0
        protected internal virtual FollowFilter Follow(string followPath)
        {
            FollowFilter followFilter = FollowFilter.Create(followPath);

            followFilter.SetRenameCallback(diffCollector);
            rw.SetTreeFilter(followFilter);
            return(followFilter);
        }
コード例 #3
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="NGit.Errors.CorruptObjectException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private void UpdateFollowFilter(ObjectId[] trees)
        {
            TreeWalk     tw        = pathFilter;
            FollowFilter oldFilter = (FollowFilter)tw.Filter;

            tw.Filter = TreeFilter.ANY_DIFF;
            tw.Reset(trees);
            IList <DiffEntry> files = DiffEntry.Scan(tw);
            RenameDetector    rd    = new RenameDetector(repository);

            rd.AddAll(files);
            files = rd.Compute();
            TreeFilter newFilter = oldFilter;

            foreach (DiffEntry ent in files)
            {
                if (IsRename(ent) && ent.GetNewPath().Equals(oldFilter.GetPath()))
                {
                    newFilter = FollowFilter.Create(ent.GetOldPath());
                    break;
                }
            }
            tw.Filter = newFilter;
        }