Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Pfeiffer2012-03-20 21:31:10 +0000
committerCarsten Pfeiffer2014-08-04 09:07:20 +0000
commit6fa83cd35b82dc0c58fa7a5e06bb088fd8eb72f9 (patch)
tree1f8b1340798bf8d18655912773b65482e2930e77 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
parent8a81846f30083e845abd04d128cd5bb1d5373151 (diff)
downloadegit-6fa83cd35b82dc0c58fa7a5e06bb088fd8eb72f9.tar.gz
egit-6fa83cd35b82dc0c58fa7a5e06bb088fd8eb72f9.tar.xz
egit-6fa83cd35b82dc0c58fa7a5e06bb088fd8eb72f9.zip
[historyView] Track renamed paths and provide to actions
Several History view actions currently fail when the view is set to follow renames since they derive the path used from the current repository path and do not take into account older paths that the resource was known as. This commit creates a simple RenameTracker class that tracks which commits introduced renames allowing the GitHistoryPage to provide the previous paths for a specific commit given the initial path. At the moment, rename tracking only works when "Show all changes of selected resource and its children" is checked, because JGit currently does not allow combining a FollowFilter with e.g. a PathFilter. The commit also makes the commit viewer's "Compare with Previous Version" honour renames. Caveat: This change unfortunately undoes some of the work in I4ae8abfc4dbe7ed772749afa80743278247585ee and my manual test coverage is pretty low (IFile and IResource only) Bug: 374722 Change-Id: Ieddbfb06418b146e5066a7ef2eda51ab4af858e2 AlsoBy: Kevin Sawicki <kevin@github.com> AlsoBy: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Carsten Pfeiffer <carsten.pfeiffer@gebit.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 636cba1859..8a27d32835 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -696,6 +696,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
private Runnable refschangedRunnable;
+ private final RenameTracker renameTracker = new RenameTracker();
+
/**
* Determine if the input can be shown in this viewer.
*
@@ -1051,6 +1053,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
if (i instanceof IWorkbenchAction)
((IWorkbenchAction) i).dispose();
}
+ renameTracker.reset(null);
super.dispose();
}
@@ -1825,6 +1828,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
fileViewerInterestingPaths = new HashSet<String>(selectedPaths);
TreeFilter followFilter = createFollowFilterFor(selectedPaths);
walk.setTreeFilter(followFilter);
+ walk.setRevFilter(renameTracker.getFilter());
+
} else if (paths.size() > 0) {
pathFilters = paths;
List<String> stringPaths = new ArrayList<String>(paths.size());
@@ -1858,9 +1863,15 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
for (String path : paths)
followFilters.add(createFollowFilter(path, diffConfig));
- if (followFilters.size() == 1)
+ if (followFilters.size() == 1) {
+ FollowFilter followFilter = (FollowFilter) followFilters.get(0);
+ renameTracker.reset(followFilter.getPath());
return followFilters.get(0);
+ }
+ // TODO: this scenario is not supported by JGit: RewriteTreeFilter
+ // can not handle composite TreeFilters and expects a plain
+ // FollowFilter for rename detection.
return OrTreeFilter.create(followFilters);
}
@@ -1869,6 +1880,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
followFilter.setRenameCallback(new RenameCallback() {
@Override
public void renamed(DiffEntry entry) {
+ renameTracker.getCallback().renamed(entry);
if (fileViewerInterestingPaths != null) {
fileViewerInterestingPaths.add(entry.getOldPath());
fileViewerInterestingPaths.add(entry.getNewPath());
@@ -2039,4 +2051,15 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
public String[] getShowInTargetIds() {
return new String[] { IHistoryView.VIEW_ID };
}
+
+ /**
+ * Get renamed path in given commit with initial starting path
+ *
+ * @param path
+ * @param commit
+ * @return actual path in commit
+ */
+ public String getRenamedPath(String path, ObjectId commit) {
+ return renameTracker.getPath(commit, path);
+ }
}

Back to the top