Re: [EGIT PATCH 4/4] Show only commits in the current branch.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Den Monday 24 March 2008 02.58.07 skrev du:
> This is a quick hack to have the functionality. It
> filters the commits returned by GitFileHistory.getHistoryFor.

Good ui, but I don't like the filter (seem you didn't either from your comment) so I suggest inserting this patch
before the 4/4 patch of yours. Then in your patch drop the filter and fix the call to getHistory. This will
improve performance since the "current branch only" will be the view I (and probably most other people)
will use the most.

@@ -868,39 +865,10 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 						.getHistoryFor(startingPoint,
 								-1,
 								monitor,
-								isShowAllRepoVersions());
+								isShowAllRepoVersions(),
+								!showOnlyCurrentBranch);
 				fileRevisions = Collections.synchronizedList(fileHistoryFor.getFileRevisionsList());

As a side note, I used the IFileHistory{,Provider} interfaces originally because they existed in Eclipse already.
The problem is that it really doesn't fit so the getHistoryFor method used is not part of those interfaces. I was just too lazy to
completely remove the interfaces yet.

-- robin

>From 5935318f49f8bcfdcae81ec12667605e42ea8d9e Mon Sep 17 00:00:00 2001
From: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>
Date: Mon, 24 Mar 2008 08:56:35 +0000
Subject: [PATCH] Add a flag to GitFileHistory to follow only current branch

Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>
---
 .../egit/core/internal/mapping/GitFileHistory.java |   17 ++++++++++++-----
 .../internal/mapping/GitFileHistoryProvider.java   |    8 +++++---
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    3 ++-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
index bdef5f1..ea1faa1 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
@@ -65,6 +65,8 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 
 	private final boolean returnAll;
 
+	private boolean allHeads;
+
 	/**
 	 * Construct a {@link GitFileHistory} object for a given resource (path)
 	 * with some filtering applied. The filter could reduce the number of
@@ -78,11 +80,14 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 	 * @param returnAll
 	 *            true if all versions should be collected even if the filter
 	 *            does not match.
+	 * @param allHeads
+	 *            true if all heads should be followed
 	 */
-	public GitFileHistory(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll) {
+	public GitFileHistory(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll, boolean allHeads) {
 		this.resource = resource;
 		this.flags = flags;
 		this.returnAll = returnAll;
+		this.allHeads = allHeads;
 		String prefix = RepositoryMapping.getMapping(resource).getSubset();
 		String[] prefixSegments = prefix!=null ? prefix.split("/") : new String[0];
 		String[] resourceSegments = resource.getProjectRelativePath().segments(); 
@@ -262,10 +267,12 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 				List<Commit> startList = new ArrayList<Commit>();
 
 				startList.add(repository.mapCommit(head));
-				for(String branch : repository.getBranches()) {
-					Commit commit = repository.mapCommit(branch);
-					if (commit != null)
-						startList.add(commit);
+				if (allHeads) {
+					for(String branch : repository.getBranches()) {
+						Commit commit = repository.mapCommit(branch);
+						if (commit != null)
+							startList.add(commit);
+					}
 				}
 				Commit[] starts = startList.toArray(new Commit[startList.size()]);
 				EclipseWalker walker = new EclipseWalker(
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
index 7847fd5..cbbfaa3 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
@@ -34,7 +34,7 @@ public class GitFileHistoryProvider extends FileHistoryProvider implements
 
 	public IFileHistory getFileHistoryFor(IResource resource, int flags,
 			IProgressMonitor monitor) {
-		return new GitFileHistory(resource, flags, monitor, false);
+		return new GitFileHistory(resource, flags, monitor, false, true);
 	}
 
 	public IFileRevision getWorkspaceFileRevision(IResource resource) {
@@ -58,12 +58,14 @@ public class GitFileHistoryProvider extends FileHistoryProvider implements
 	 *            progress monitor
 	 * @param returnAll
 	 *            true if all revisions are returned and interesting revisions marked.
+	 * @param allHeads
+	 *            true if all heads should be followed
 	 *
 	 * @return a {@link GitFileHistory} object.
 	 *
 	 */
-	public GitFileHistory getHistoryFor(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll) {
-		return new GitFileHistory(resource, flags, monitor, returnAll); // TODO: implement flags
+	public GitFileHistory getHistoryFor(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll, boolean allHeads) {
+		return new GitFileHistory(resource, flags, monitor, returnAll, allHeads);
 	}
 
 }
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index d0346a9..984e54e 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -840,7 +840,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 						.getHistoryFor(startingPoint,
 								-1,
 								monitor,
-								isShowAllRepoVersions());
+								isShowAllRepoVersions(),
+								true);
 				fileRevisions = Collections.synchronizedList(fileHistoryFor.getFileRevisionsList());
 				findToolbar.setFileRevisions(fileRevisions, newtags, branches);
 				Display.getDefault().syncExec(new Runnable() {
-- 
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux