/// <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;
        }
Example #2
0
 /// <summary>Enable (or disable) following file renames, on by default.</summary>
 /// <remarks>
 /// Enable (or disable) following file renames, on by default.
 /// <p>
 /// If true renames are followed using the standard FollowFilter behavior
 /// used by RevWalk (which matches
 /// <code>git log --follow</code>
 /// in the C
 /// implementation). This is not the same as copy/move detection as
 /// implemented by the C implementation's of
 /// <code>git blame -M -C</code>
 /// .
 /// </remarks>
 /// <param name="follow">enable following.</param>
 /// <returns>
 ///
 /// <code>this</code>
 /// </returns>
 public virtual NGit.Blame.BlameGenerator SetFollowFileRenames(bool follow)
 {
     if (follow)
     {
         renameDetector = new RenameDetector(GetRepository());
     }
     else
     {
         renameDetector = null;
     }
     return(this);
 }
Example #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;
        }
Example #4
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;
 }
Example #5
0
		public override void SetUp()
		{
			base.SetUp();
			testDb = new TestRepository<FileRepository>(db);
			rd = new RenameDetector(db);
		}
		/// <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;
		}