/// <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; }
/// <exception cref="System.IO.IOException"></exception> private DiffEntry FindRename(RevCommit parent, RevCommit commit, PathFilter path) { if (renameDetector == null) { return(null); } treeWalk.Filter = TreeFilter.ANY_DIFF; treeWalk.Reset(parent.Tree, commit.Tree); renameDetector.AddAll(DiffEntry.Scan(treeWalk)); foreach (DiffEntry ent in renameDetector.Compute()) { if (IsRename(ent) && ent.GetNewPath().Equals(path.GetPath())) { return(ent); } } return(null); }
/// <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; }
/// <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; }
/// <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; }