git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [EGIT 00/10] This weeks Eclipse patches
@ 2007-05-07 21:29 Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API Robin Rosenberg
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

A random collection of improvements to the Eclipse
plugin.

Highlights:
        - Now compatible with Eclipse 3.2.1 through 3.3 M7
        - Update compare view immediately when selecting a commit
          with the left button.
        - Compare with previous menu item, not just two selected
          commits.
	- Tooltip with full comment in history view
        - Minor performance and API enhancements
	- New bugs (FREE, apply now!)

You'll need Sun's JDK version 1.6 to run gracefully since the
memory mapping stresses the GC. With older versions you will get
out of memory errors needlessly, which currently means the
implementation does not see all objects.

-- robin 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 02/10] Recursion and update of all elements regardless of need Robin Rosenberg
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

There were changes made in Eclipse 3.3M7 that
blew our cover. Apparently we were not using the
API:s properly. Hopefully this is somewhat better.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../actions/CompareWithRevisionAction.java         |    5 ++---
 .../actions/ShowResourceInHistoryAction.java       |    5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
index 9cded79..981c14c 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
@@ -22,14 +22,13 @@ import java.util.Hashtable;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
 import org.eclipse.team.internal.ui.actions.TeamAction;
 import org.eclipse.team.ui.TeamUI;
 import org.eclipse.team.ui.history.HistoryPageSaveablePart;
 
 public class CompareWithRevisionAction extends TeamAction {
 
-	public void run(IAction action) {
+	public void execute(IAction action) {
 		super.run(action);
 		System.out.println("Run:" + action);
 		System.out.println("Selection resources:"
@@ -45,7 +44,7 @@ public class CompareWithRevisionAction extends TeamAction {
 		HistoryPageSaveablePart.showHistoryInDialog(shell, object);
 	}
 
-	protected boolean isEnabled() throws TeamException {
+	public boolean isEnabled() {
 		return !getSelection().isEmpty();
 	}
 
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
index db6f3e2..d2f9c47 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
@@ -18,14 +18,13 @@ package org.spearce.egit.ui.internal.actions;
 
 import org.eclipse.jface.action.IAction;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
 import org.eclipse.team.internal.ui.actions.TeamAction;
 import org.eclipse.team.ui.TeamUI;
 import org.eclipse.team.ui.history.HistoryPageSaveablePart;
 
 public class ShowResourceInHistoryAction extends TeamAction {
 
-	public void run(IAction action) {
+	public void execute(IAction action) {
 		TeamUI.getHistoryView().showHistoryFor(getSelectedResources()[0]);
 	}
 
@@ -33,7 +32,7 @@ public class ShowResourceInHistoryAction extends TeamAction {
 		HistoryPageSaveablePart.showHistoryInDialog(shell, object);
 	}
 
-	protected boolean isEnabled() throws TeamException {
+	public boolean isEnabled() {
 		return !getSelection().isEmpty();
 	}
 }

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 02/10] Recursion and update of all elements regardless of need.
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 03/10] Update compare window immediately Robin Rosenberg
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

When selecting an element in the history view viewer.updateElement
is called for every element recursively. If the number of
elements is very largs this results in a stack overflow. This
only happens with Eclipse 3.3 M7 and not M6.

Is it thig bug? https://bugs.eclipse.org/bugs/show_bug.cgi?id=149642

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

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 7bc947b..8be23ec 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
@@ -281,6 +281,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 
 		viewer = new TreeViewer(tree, SWT.VIRTUAL | SWT.FULL_SELECTION);
 
+		viewer.setUseHashlookup(true);
+
 		createColumns();
 
 		viewer.setLabelProvider(new GitHistoryLabelProvider());
@@ -354,6 +356,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		}
 
 		public void updateElement(Object parent, int index) {
+			System.out.println("updateElement("+parent+","+index);
 			viewer.replace(parent, index, fileRevisions[index]);
 		}
 	}

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 03/10] Update compare window immediately
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 02/10] Recursion and update of all elements regardless of need Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 04/10] Bug: Do not crash when showing diff for first version of a file Robin Rosenberg
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

Compute the commit diff for the selected revision in the history
view immediately when one version is selected if selection is
made with the left mouse button and a compare window is already
open. Thanks to the way git data structures are designed the diff
is usually instantenous.

We can't have it this way in the long run. Figure out something
better, like adding an icon to the history view for selecting
behaviour. Another ugly hack is the way I detect which mouse
button was clicked, if any so that right-clicking on a history
item does not cause the diff to be changed.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../src/org/spearce/egit/ui/GitHistoryPage.java    |   47 +++++++++++++++++++----
 1 files changed, 38 insertions(+), 9 deletions(-)

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 8be23ec..4b437a6 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
@@ -18,6 +18,7 @@ package org.spearce.egit.ui;
 
 import java.io.IOException;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.compare.CompareConfiguration;
@@ -42,6 +43,8 @@ import org.eclipse.jface.viewers.TableLayout;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Image;
@@ -83,6 +86,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 
 	private IFileRevision[] fileRevisions;
 
+	protected boolean hintShowDiffNow;
+
 	public GitHistoryPage(Object object) {
 		setInput(object);
 	}
@@ -114,6 +119,20 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				"Compare");
 		final GitCompareRevisionAction compareActionPrev = new GitCompareRevisionAction(
 				"Show commit");
+		tree.addMouseListener(new MouseListener() {
+		
+			public void mouseUp(MouseEvent e) {
+			}
+		
+			public void mouseDown(MouseEvent e) {
+				hintShowDiffNow = e.button==1;
+			}
+		
+			public void mouseDoubleClick(MouseEvent e) {
+			}
+		
+		});
+
 		tree.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
 				// update the current
@@ -130,16 +149,25 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				GitProvider provider = (GitProvider)RepositoryProvider
 						.getProvider(project);
 				RepositoryMapping repositoryMapping = provider.getData().getRepositoryMapping(project);
-				ObjectId parentId = (ObjectId)((GitFileRevision)selection2[0]).getCommit().getParentIds().get(0);
 				try {
-					if (selection2.length == 1) {
-						Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
-						IFileRevision previous = new GitFileRevision(parent,
-								((GitFileRevision)selection2[0]).getResource(),
-								((GitFileRevision)selection2[0]).getCount()+1);
-//						compareActionPrev.setCurrentFileRevision(selection2[0]);
-						compareActionPrev.setCurrentFileRevision(null);
-						compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[] {selection2[0], previous}));
+					if (selection2.length == 1 && hintShowDiffNow) {
+						List parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
+						if (parentIds.size() > 0) {
+							ObjectId parentId = (ObjectId)parentIds.get(0);
+							Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
+							IFileRevision previous = new GitFileRevision(parent,
+									((GitFileRevision)selection2[0]).getResource(),
+									((GitFileRevision)selection2[0]).getCount()+1);
+							compareActionPrev.setCurrentFileRevision(null);
+							compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[] {selection2[0], previous}));
+							System.out.println("detail="+e.detail);
+							tree.getDisplay().asyncExec(new Runnable() {
+								public void run() {
+									if (GitCompareRevisionAction.findReusableCompareEditor(GitHistoryPage.this.getSite().getPage()) != null)
+										compareActionPrev.run();
+								}
+							});
+						}
 					} else {
 						compareActionPrev.setCurrentFileRevision(null);
 						compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[0]));
@@ -148,6 +176,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 					// TODO Auto-generated catch block
 					e1.printStackTrace();
 				}
+				hintShowDiffNow = false;
 			}
 		});
 		compareAction.setPage(this);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 04/10] Bug: Do not crash when showing diff for first version of a file
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (2 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 03/10] Update compare window immediately Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 05/10] Speed up ObjectId a little Robin Rosenberg
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

We crashed because the right side did not contain any information

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../spearce/egit/ui/internal/GitResourceNode.java  |   28 ++++++++++++++---------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
index bdf8902..010b738 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
@@ -70,7 +70,10 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
 	}
 
 	public String getName() {
-		return entry.getFullName();
+		if (entry != null)
+			return entry.getFullName();
+		else
+			return "<none>";
 	}
 
 	public Image getImage() {
@@ -81,16 +84,19 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
 		if (entry instanceof Tree)
 			return ITypedElement.FOLDER_TYPE;
 		else {
-			String name = entry.getName();
-			if (name != null) {
-				int index = name.lastIndexOf('.');
-				if (index == -1)
-					return ""; //$NON-NLS-1$
-				if (index == (name.length() - 1))
-					return ""; //$NON-NLS-1$
-				return name.substring(index + 1);
-			}
-			return "";
+			if (entry != null) {
+				String name = entry.getName();
+				if (name != null) {
+					int index = name.lastIndexOf('.');
+					if (index == -1)
+						return ""; //$NON-NLS-1$
+					if (index == (name.length() - 1))
+						return ""; //$NON-NLS-1$
+					return name.substring(index + 1);
+				}
+				return "";
+			} else
+				return "";
 		}
 	}
 

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 05/10] Speed up ObjectId a little.
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (3 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 04/10] Bug: Do not crash when showing diff for first version of a file Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 06/10] Create a generic history walker Robin Rosenberg
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

ObjectId size if fixed so we can exploit this fact.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../src/org/spearce/jgit/lib/ObjectId.java         |   29 ++++++++++++++---------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
index 45e23e6..fea0d91 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -86,7 +86,7 @@ public class ObjectId implements Comparable {
 	private static int compare(final byte[] a, final byte[] b) {
 		if (a==b)
 			return 0;
-		for (int k = 0; k < a.length && k < b.length; k++) {
+		for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
 			final int ak = a[k] & 0xff;
 			final int bk = b[k] & 0xff;
 			if (ak < bk)
@@ -94,7 +94,11 @@ public class ObjectId implements Comparable {
 			else if (ak > bk)
 				return 1;
 		}
-		return a.length == b.length ? 0 : a.length < b.length ? -1 : 1;
+		if (a.length != Constants.OBJECT_ID_LENGTH)
+			throw new IllegalArgumentException("Looks like a bad object id");
+		if (b.length != Constants.OBJECT_ID_LENGTH)
+			throw new IllegalArgumentException("Looks like a bad object id");
+		return 0;
 	}
 
 	private final byte[] id;
@@ -106,9 +110,11 @@ public class ObjectId implements Comparable {
 		}
 
 		id = new byte[Constants.OBJECT_ID_LENGTH];
+		char[] bs = new char[Constants.OBJECT_ID_LENGTH*2];
+		i.getChars(0,Constants.OBJECT_ID_LENGTH*2,bs,0);
 		for (int j = 0, k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
-			final char c1 = i.charAt(j++);
-			final char c2 = i.charAt(j++);
+			final char c1 = bs[j++];
+			final char c2 = bs[j++];
 			int b;
 
 			if ('0' <= c1 && c1 <= '9') {
@@ -181,7 +187,7 @@ public class ObjectId implements Comparable {
 	}
 
 	public void copyTo(final OutputStream w) throws IOException {
-		for (int k = 0; k < id.length; k++) {
+		for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
 			final int b = id[k];
 			final int b1 = (b >> 4) & 0xf;
 			final int b2 = b & 0xf;
@@ -191,7 +197,7 @@ public class ObjectId implements Comparable {
 	}
 
 	public void copyTo(final Writer w) throws IOException {
-		for (int k = 0; k < id.length; k++) {
+		for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
 			final int b = id[k];
 			final int b1 = (b >> 4) & 0xf;
 			final int b2 = b & 0xf;
@@ -201,14 +207,15 @@ public class ObjectId implements Comparable {
 	}
 
 	public String toString() {
-		final StringBuffer r = new StringBuffer(2 * id.length);
-		for (int k = 0; k < id.length; k++) {
+		byte s[] = new byte[Constants.OBJECT_ID_LENGTH*2];
+		int i = 0;
+		for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
 			final int b = id[k];
 			final int b1 = (b >> 4) & 0xf;
 			final int b2 = b & 0xf;
-			r.append(b1 < 10 ? (char) ('0' + b1) : (char) ('a' + b1 - 10));
-			r.append(b2 < 10 ? (char) ('0' + b2) : (char) ('a' + b2 - 10));
+			s[i++] = (b1 < 10 ? (byte) ('0' + b1) : (byte) ('a' + b1 - 10));
+			s[i++] = (b2 < 10 ? (byte) ('0' + b2) : (byte) ('a' + b2 - 10));
 		}
-		return r.toString();
+		return new String(s,0);
 	}
 }

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 06/10] Create a generic history walker
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (4 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 05/10] Speed up ObjectId a little Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 07/10] Cache pack index fully Robin Rosenberg
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

This was needed to created a performance test program. This
is a very stupid walker so far since it only follows the
first parent. The main reason is that the viewer is not
capable of more. The only reason it is usable to me is that
most projects I work on have few branches and even fewer
merges (that can be detected by CVS converters).

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../egit/core/internal/mapping/GitFileHistory.java |  149 ++++++-----------------
 .../src/org/spearce/jgit/lib/Walker.java           |  134 +++++++++++++++++++++
 .../tst/org/spearce/jgit/lib/T0007_WalkerTest.java |   63 ++++++++++
 3 files changed, 233 insertions(+), 113 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 0569862..71b29ce 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
@@ -20,9 +20,7 @@ import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -42,6 +40,7 @@ import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
+import org.spearce.jgit.lib.Walker;
 
 public class GitFileHistory extends FileHistory implements IAdaptable {
 
@@ -110,124 +109,30 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 		return getData().getRepositoryMapping(resource.getProject());
 	}
 
-	private Collection collectHistory() {
-		Repository repository = getRepository();
-		try {
-			ObjectId id = repository.resolve("HEAD");
-			Commit commit = repository.mapCommit(id);
-			ObjectId[] initialResourceHash = new ObjectId[relativeResourceName.length];
-			Arrays.fill(initialResourceHash, ObjectId.zeroId());
-			TreeEntry[] activeDiffTreeEntries = null;
-			try {
-				activeDiffTreeEntries = getData().getActiveDiffTreeEntries(resource);
-			} catch (CoreException e1) {
-				// TODO: eclipse excetion logging
-				e1.printStackTrace();
-			}
-			if (activeDiffTreeEntries!=null)
-				initialResourceHash[initialResourceHash.length-1] = activeDiffTreeEntries[0].getId();
-			return collectHistory(0, initialResourceHash, null,
-					repository, commit);
-		} catch (IOException e) {
-			e.printStackTrace();
-			return Collections.EMPTY_LIST;
-		}
+static class EclipseWalker extends Walker {
+	IResource resource;
+	
+	EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId) {
+		super(repository, start, relativeResourceName, leafIsBlob, followMainOnly, lastActiveDiffId);
+		this.resource = resource;
 	}
 
-	private Collection collectHistory(int count, ObjectId[] lastResourceHash, TreeEntry lastEntry,
-			Repository repository, Commit top) throws IOException {
-		if (top == null)
-			return Collections.EMPTY_LIST;
-		Collection ret = new ArrayList(10000);
-		Commit current = top;
-		Commit previous = top;
-
-		do {
-			TreeEntry currentEntry = lastEntry;
-			ObjectId[] currentResourceHash = new ObjectId[lastResourceHash.length];
-			Tree t = current.getTree();
-			for (int i = 0; i < currentResourceHash.length; ++i) {
-				TreeEntry m;
-				if (i == relativeResourceName.length-1 && resource.getType() == IResource.FILE)
-					m = t.findBlobMember(relativeResourceName[i]);
-				else
-					m = t.findTreeMember(relativeResourceName[i]);
-				if (m != null) {
-					ObjectId id = m.getId();
-					currentResourceHash[i] = id;
-					if (id.equals(lastResourceHash[i])) {
-						while (++i < currentResourceHash.length) {
-							currentResourceHash[i] = lastResourceHash[i];
-						}
-					} else {
-						if (m instanceof Tree) {
-							t = (Tree)m;
-						} else {
-							if (i == currentResourceHash.length - 1) {
-								currentEntry = m;
-							} else {
-								currentEntry = null;
-								while (++i < currentResourceHash.length) {
-									currentResourceHash[i] = ObjectId.zeroId();
-								}
-							}
-						}
-					}
-				} else {
-					for (; i < currentResourceHash.length; ++i) {
-						currentResourceHash[i] = ObjectId.zeroId();
-					}
-				}
-			}
-			
-			if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
-				ret.add(new GitFileRevision(previous, resource, count));
-
-			lastResourceHash = currentResourceHash;
-			previous = current;
-
-			// TODO: we may need to list more revisions when traversing
-			// branches
-			List parents = current.getParentIds();
-			if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0) {
-				for (int i = 1; i < parents.size(); ++i) {
-					ObjectId mergeParentId = (ObjectId) parents.get(i);
-					Commit mergeParent;
-					try {
-						mergeParent = repository.mapCommit(mergeParentId);
-						ret.addAll(collectHistory(0, lastResourceHash, currentEntry, repository, 
-								mergeParent));
-						// TODO: this gets us a lot of duplicates that we need
-						// to filter out
-						// Leave that til we get a GUI.
-					} catch (IOException e) {
-						e.printStackTrace();
-					}
-				}
-			}
-			if (parents.size() > 0) {
-				ObjectId parentId = (ObjectId) parents.get(0);
-				try {
-					current = repository.mapCommit(parentId);
-				} catch (IOException e) {
-					e.printStackTrace();
-					current = null;
-				}
-			} else
-				current = null;
-			if (count>=0)
-				count++;
-		} while (current != null);
-
-		return ret;
+	protected void collect(Collection ret,Commit commit, int count) {
+		ret.add(new GitFileRevision(commit, resource, count));		
 	}
+	
+};
 
 	public IFileRevision[] getFileRevisions() {
 		if (revisions == null)
 			if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0)
 				findSingleRevision();
 			else
-				findRevisions();
+				try {
+					findRevisions();
+				} catch (IOException e) {
+					throw new Error(e);
+				}
 		return revisions;
 	}
 
@@ -272,7 +177,7 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 		}
 	}
 
-	private void findRevisions() {
+	private void findRevisions() throws IOException {
 		RepositoryProvider provider = RepositoryProvider.getProvider(resource
 				.getProject());
 		if (provider instanceof GitProvider) {
@@ -281,7 +186,25 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 			long time0 = new Date().getTime();
 			System.out.println("getting file history");
 			List ret = new ArrayList();
-			Collection githistory = collectHistory();
+			TreeEntry[] activeDiffTreeEntries = null;
+			try {
+				activeDiffTreeEntries = getData().getActiveDiffTreeEntries(resource);
+			} catch (CoreException e1) {
+				// TODO: eclipse excetion logging
+				e1.printStackTrace();
+			}
+			ObjectId activeDiffLeafId = null;
+			if (activeDiffTreeEntries!=null)
+				activeDiffLeafId = activeDiffTreeEntries[0].getId();
+
+			ObjectId head = getRepository().resolve("HEAD");
+			Commit start = getRepository().mapCommit(head);
+			EclipseWalker walker = new EclipseWalker(getRepository(), start, relativeResourceName, 
+					resource.getType() == IResource.FILE, 
+					resource, 
+					(flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0,
+					activeDiffLeafId);
+			Collection githistory = walker.collectHistory();
 			if (githistory.size() >0) {
 				if (resource.getType()==IResource.FILE) {
 					// TODO: consider index in future versions
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
new file mode 100644
index 0000000..2928e1d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -0,0 +1,134 @@
+/**
+ * 
+ */
+package org.spearce.jgit.lib;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class Walker {
+	private String[] relativeResourceName;
+	private boolean leafIsBlob;
+	private boolean followMainOnly;
+	private Repository repository;
+	private ObjectId activeDiffLeafId;
+	private final Commit start;
+
+	protected abstract void collect(Collection ret,Commit commit, int count);
+
+	protected Walker(Repository repostory, Commit start, String[] relativeResourceName,boolean leafIsBlob,boolean followMainOnly, ObjectId activeDiffLeafId) {
+		this.repository = repostory;
+		this.start = start;
+		this.relativeResourceName = relativeResourceName;
+		this.leafIsBlob = leafIsBlob;
+		this.followMainOnly = followMainOnly;
+		this.activeDiffLeafId = activeDiffLeafId;
+	}
+	
+	public Collection collectHistory() {
+		try {
+			Commit commit = start;
+			ObjectId[] initialResourceHash = new ObjectId[relativeResourceName.length];
+			Arrays.fill(initialResourceHash, ObjectId.zeroId());
+			if (activeDiffLeafId != null)
+				initialResourceHash[initialResourceHash.length-1] = activeDiffLeafId;
+			return collectHistory(0, initialResourceHash, null,
+					repository, commit);
+		} catch (IOException e) {
+			e.printStackTrace();
+			return Collections.EMPTY_LIST;
+		}
+	}
+
+	Collection collectHistory(int count, ObjectId[] lastResourceHash, TreeEntry lastEntry,
+			Repository repository, Commit top) throws IOException {
+		if (top == null)
+			return Collections.EMPTY_LIST;
+		Collection ret = new ArrayList(10000);
+		Commit current = top;
+		Commit previous = top;
+
+		do {
+			TreeEntry currentEntry = lastEntry;
+			ObjectId[] currentResourceHash = new ObjectId[lastResourceHash.length];
+			Tree t = current.getTree();
+			for (int i = 0; i < currentResourceHash.length; ++i) {
+				TreeEntry m;
+				if (i == relativeResourceName.length-1 && leafIsBlob)
+					m = t.findBlobMember(relativeResourceName[i]);
+				else
+					m = t.findTreeMember(relativeResourceName[i]);
+				if (m != null) {
+					ObjectId id = m.getId();
+					currentResourceHash[i] = id;
+					if (id.equals(lastResourceHash[i])) {
+						while (++i < currentResourceHash.length) {
+							currentResourceHash[i] = lastResourceHash[i];
+						}
+					} else {
+						if (m instanceof Tree) {
+							t = (Tree)m;
+						} else {
+							if (i == currentResourceHash.length - 1) {
+								currentEntry = m;
+							} else {
+								currentEntry = null;
+								while (++i < currentResourceHash.length) {
+									currentResourceHash[i] = ObjectId.zeroId();
+								}
+							}
+						}
+					}
+				} else {
+					for (; i < currentResourceHash.length; ++i) {
+						currentResourceHash[i] = ObjectId.zeroId();
+					}
+				}
+			}
+			
+			if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1])) {
+				collect(ret, previous, count);
+			}
+			lastResourceHash = currentResourceHash;
+			previous = current;
+
+			// TODO: we may need to list more revisions when traversing
+			// branches
+			List parents = current.getParentIds();
+			if (!followMainOnly) {
+				for (int i = 1; i < parents.size(); ++i) {
+					ObjectId mergeParentId = (ObjectId) parents.get(i);
+					Commit mergeParent;
+					try {
+						mergeParent = repository.mapCommit(mergeParentId);
+						ret.addAll(collectHistory(0, lastResourceHash, currentEntry, repository, 
+								mergeParent));
+						// TODO: this gets us a lot of duplicates that we need
+						// to filter out
+						// Leave that til we get a GUI.
+					} catch (IOException e) {
+						e.printStackTrace();
+					}
+				}
+			}
+			if (parents.size() > 0) {
+				ObjectId parentId = (ObjectId) parents.get(0);
+				try {
+					current = repository.mapCommit(parentId);
+				} catch (IOException e) {
+					e.printStackTrace();
+					current = null;
+				}
+			} else
+				current = null;
+			if (count>=0)
+				count++;
+		} while (current != null);
+
+		return ret;
+	}
+}
\ No newline at end of file
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
new file mode 100644
index 0000000..82f0623
--- /dev/null
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
@@ -0,0 +1,63 @@
+/*
+ *  Copyright (C) 2006  Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License, version 2.1, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import junit.textui.TestRunner;
+
+/**
+ * A performance test like T0006_DeepSpeedTest, but more
+ * realistic since it is smarter.
+ */
+public class T0007_WalkerTest extends SpeedTestBase {
+
+	protected void setUp() throws Exception {
+		prepare(new String[] { "git", "log", "365bbe0d0caaf2ba74d56556827babf0bc66965d","--","net/netfilter/nf_queue.c" });
+	}
+
+	public void testHistoryScan() throws IOException {
+//		long start = System.currentTimeMillis();
+		Repository db = new Repository(new File(kernelrepo));
+		String[] path = { "net", "netfilter", "nf_queue.c" };
+		Walker walker = new Walker(db,db.mapCommit(new ObjectId("365bbe0d0caaf2ba74d56556827babf0bc66965d")),path,true,true,null) {
+
+			protected void collect(Collection ret, Commit commit, int count) {
+				System.out.println("Got: "+count+" "+commit.getCommitId());
+				ret.add(commit);
+			}
+		
+		};
+		Commit[] history = (Commit[])walker.collectHistory().toArray(new Commit[0]);
+		assertEquals(8, history.length);
+		assertEquals("365bbe0d0caaf2ba74d56556827babf0bc66965d",history[0].getCommitId().toString());
+		assertEquals("a4c12d6c5dde48c69464baf7c703e425ee511433",history[1].getCommitId().toString());
+		assertEquals("761a126017e3f001d3f5a574787aa232a9cd5bb5",history[2].getCommitId().toString());
+		assertEquals("22a3e233ca08a2ddc949ba1ae8f6e16ec7ef1a13",history[3].getCommitId().toString());
+		assertEquals("460fbf82c0842cad3f3c744c4dcb81978b7829f3",history[4].getCommitId().toString());
+		assertEquals("272a5322d5219b00a1e541ad9d0d76824df1aa2a",history[5].getCommitId().toString());
+		assertEquals("8e33ba49765484bc6de3a2f8143733713fa93bc1",history[6].getCommitId().toString());
+		assertEquals("826509f8110049663799bc20f2b5b6170e2f78ca",history[7].getCommitId().toString());
+		
+	}
+
+	public static void main(String[] args) {
+		TestRunner.run(T0007_WalkerTest.class);
+	}
+}

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 07/10] Cache pack index fully
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (5 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 06/10] Create a generic history walker Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:29 ` [EGIT PATCH 08/10] Use ObjectId[] instead of List for parents Robin Rosenberg
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

Navigating the pack index for every lookup takes time, mostly
because it takes resources from the memory mapping for getting
the actual objects.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../jgit/lib/DeltaRefPackedObjectLoader.java       |    3 
 .../src/org/spearce/jgit/lib/ObjectId.java         |   17 ++
 .../src/org/spearce/jgit/lib/ObjectIdMap.java      |  145 ++++++++++++++++++++
 .../src/org/spearce/jgit/lib/PackFile.java         |   87 ++++++------
 .../src/org/spearce/jgit/lib/Repository.java       |   17 +-
 .../tst/org/spearce/jgit/lib/ObjectIdMapTest.java  |  170 +++++++++++++++++++++++
 .../tst/org/spearce/jgit/lib/T0004_PackReader.java |    2 
 7 files changed, 377 insertions(+), 64 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java b/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
index 2719738..90c01ea 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
@@ -15,8 +15,7 @@ class DeltaRefPackedObjectLoader extends DeltaPackedObjectLoader {
 	}
 
 	protected ObjectLoader getBaseLoader() throws IOException {
-		final ObjectLoader or = pack.get(deltaBase,
-				new byte[Constants.OBJECT_ID_LENGTH]);
+		final ObjectLoader or = pack.get(deltaBase);
 		if (or == null)
 			throw new MissingObjectException(deltaBase, "delta base");
 		return or;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
index fea0d91..f99c303 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -83,10 +83,20 @@ public class ObjectId implements Comparable {
 		return new ObjectId(id);
 	}
 
-	private static int compare(final byte[] a, final byte[] b) {
-		if (a==b)
-			return 0;
+	public int compareTo(byte[] b, long pos) {
 		for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
+			final int ak = id[k] & 0xff;
+			final int bk = b[k + (int)pos] & 0xff;
+			if (ak < bk)
+				return -1;
+			else if (ak > bk)
+				return 1;
+		}
+		return 0;
+	}
+
+	private static int compare(final byte[] a, final byte[] b) {
+		for (int k = 0 ; k < Constants.OBJECT_ID_LENGTH; k++) {
 			final int ak = a[k] & 0xff;
 			final int bk = b[k] & 0xff;
 			if (ak < bk)
@@ -218,4 +228,5 @@ public class ObjectId implements Comparable {
 		}
 		return new String(s,0);
 	}
+
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
new file mode 100644
index 0000000..c397a0d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
@@ -0,0 +1,145 @@
+/*
+ *  Copyright (C) 2006  Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License, version 2, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/** Very much like a map, but specialized
+ *  to partition the data on the first byte
+ *  of the key. This is MUCH faster. See test
+ *  class for how these numbers were derived.
+ *  
+ *	TreeMap=            2968
+ *	HashMap=            1689
+ *	Partitioned TreeMap=1499
+ *	Partitioned HashMap=1782
+ *
+ *  Inspiration from Git pack file format which uses this technique.
+ *  
+ */
+public class ObjectIdMap implements Map {
+
+	Map[] level0 = new Map[256];
+	
+	public ObjectIdMap() {
+		this(new TreeMap());
+	}
+
+	public ObjectIdMap(Map sample) {
+		try {
+			Method m=sample.getClass().getMethod("clone", null);
+			for (int i=0; i<256; ++i) {
+				level0[i] = (Map)m.invoke(sample, null);
+			}
+		} catch (IllegalAccessException e) {
+			throw new IllegalArgumentException(e);
+		} catch (IllegalArgumentException e) {
+			throw new IllegalArgumentException(e);
+		} catch (InvocationTargetException e) {
+			throw new IllegalArgumentException(e);
+		} catch (SecurityException e) {
+			throw new IllegalArgumentException(e);
+		} catch (NoSuchMethodException e) {
+			throw new IllegalArgumentException(e);
+		}
+	}
+	
+	public void clear() {
+		for (int i=0; i<256; ++i)
+			level0[i].clear();
+	}
+
+	public boolean containsKey(Object key) {
+		return submap(key).containsKey(key);
+	}
+
+	private final Map submap(Object key) {
+		return level0[((ObjectId)key).getFirstByte()];
+	}
+
+	public boolean containsValue(Object value) {
+		for (int i=0; i<256; ++i)
+			if (level0[i].containsValue(value))
+				return true;
+		return false;
+	}
+
+	public Set entrySet() {
+		Set ret = new HashSet();
+		for (int i=0; i<256; ++i)
+			ret.addAll(level0[i].entrySet());
+		return ret;
+	}
+
+	public Object get(Object key) {
+		return submap(key).get(key);
+	}
+
+	public boolean isEmpty() {
+		for (int i=0; i<256; ++i)
+			if (!level0[i].isEmpty())
+				return false;
+		return true;
+	}
+
+	public Set keySet() {
+		Set ret = new HashSet();
+		for (int i=0; i<256; ++i)
+			ret.addAll(level0[i].keySet());
+		return ret;
+	}
+
+	public Object put(Object key, Object value) {
+		return submap(key).put(key, value);
+	}
+
+	public void putAll(Map arg0) {
+		for (Iterator i=arg0.keySet().iterator(); i.hasNext(); ) {
+			Object k=i.next();
+			Object v=arg0.get(k);
+			put(k,v);
+		}
+	}
+
+	public Object remove(Object key) {
+		return submap(key).remove(key);
+	}
+
+	public int size() {
+		int ret=0;
+		for (int i=0; i<256; ++i)
+			ret += level0[i].size();
+		return ret;
+	}
+
+	public Collection values() {
+		List ret=new ArrayList(size());
+		for (int i=0; i<256; ++i)
+			ret.addAll(level0[i].values());
+		return ret;
+	}
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
index d33aa97..fa206fd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
@@ -32,8 +32,7 @@ public class PackFile {
 	private final WindowedFile pack;
 
 	private final WindowedFile idx;
-
-	private final long[] idxHeader;
+	private byte[][] idxdata;
 
 	private long objectCnt;
 
@@ -52,10 +51,9 @@ public class PackFile {
 					.substring(0, dot)
 					+ ".idx");
 			// FIXME window size and mmap type should be configurable
-			idx = new WindowedFile(repo.getWindowCache(), idxFile,
-					64 * 1024 * 1024, true);
+			idx = new WindowedFile(new WindowCache(8*1024*1024,1), idxFile, 8*1024*1024, true);
 			try {
-				idxHeader = readIndexHeader();
+				readIndexHeader();
 			} catch (IOException ioe) {
 				try {
 					idx.close();
@@ -75,7 +73,7 @@ public class PackFile {
 	}
 
 	ObjectLoader resolveBase(final long ofs) throws IOException {
-		return reader(ofs, new byte[Constants.OBJECT_ID_LENGTH]);
+		return reader(ofs);
 	}
 
 	/**
@@ -87,19 +85,10 @@ public class PackFile {
 	 * 
 	 * @param id
 	 *            the object to look for. Must not be null.
-	 * @param tmp
-	 *            a temporary buffer loaned to this pack for use during the
-	 *            search. This buffer must be at least
-	 *            {@link Constants#OBJECT_ID_LENGTH} bytes in size. The buffer
-	 *            will be overwritten during the search, but is unused upon
-	 *            return.
 	 * @return true if the object is in this pack; false otherwise.
-	 * @throws IOException
-	 *             there was an error reading data from the pack's index file.
 	 */
-	public boolean hasObject(final ObjectId id, final byte[] tmp)
-			throws IOException {
-		return findOffset(id, tmp) != -1;
+	public boolean hasObject(final ObjectId id) {
+		return findOffset(id) != -1;
 	}
 
 	/**
@@ -116,25 +105,17 @@ public class PackFile {
 	 * 
 	 * @param id
 	 *            the object to obtain from the pack. Must not be null.
-	 * @param tmp
-	 *            a temporary buffer loaned to this pack for use during the
-	 *            search, and given to the returned loader if the object is
-	 *            found. This buffer must be at least
-	 *            {@link Constants#OBJECT_ID_LENGTH} bytes in size. The buffer
-	 *            will be overwritten during the search. The buffer will be
-	 *            given to the loader if a loader is returned. If null is
-	 *            returned the caller may reuse the buffer.
 	 * @return the object loader for the requested object if it is contained in
 	 *         this pack; null if the object was not found.
 	 * @throws IOException
 	 *             the pack file or the index could not be read.
 	 */
-	public PackedObjectLoader get(final ObjectId id, final byte[] tmp)
+	public PackedObjectLoader get(final ObjectId id)
 			throws IOException {
-		final long offset = findOffset(id, tmp);
+		final long offset = findOffset(id);
 		if (offset == -1)
 			return null;
-		final PackedObjectLoader objReader = reader(offset, tmp);
+		final PackedObjectLoader objReader = reader(offset);
 		objReader.setId(id);
 		return objReader;
 	}
@@ -173,22 +154,35 @@ public class PackFile {
 		objectCnt = pack.readUInt32(position, intbuf);
 	}
 
-	private long[] readIndexHeader() throws CorruptObjectException, IOException {
+	private void readIndexHeader() throws CorruptObjectException, IOException {
 		if (idx.length() != (IDX_HDR_LEN + (24 * objectCnt) + (2 * Constants.OBJECT_ID_LENGTH)))
 			throw new CorruptObjectException("Invalid pack index");
 
-		final long[] idxHeader = new long[256];
+		final long[] idxHeader = new long[256]; // really unsigned 32-bit...
 		final byte[] intbuf = new byte[4];
 		for (int k = 0; k < idxHeader.length; k++)
 			idxHeader[k] = idx.readUInt32(k * 4, intbuf);
-		return idxHeader;
+		idxdata = new byte[idxHeader.length][];
+		for (int k = 0; k < idxHeader.length; k++) {
+			int n;
+			if (k == 0) {
+				n = (int)(idxHeader[k]);
+			} else {
+				n = (int)(idxHeader[k]-idxHeader[k-1]);
+			}
+			if (n > 0) {
+				idxdata[k] = new byte[n * (Constants.OBJECT_ID_LENGTH + 4)];
+				int off = (int) ((k == 0) ? 0 : idxHeader[k-1] * (Constants.OBJECT_ID_LENGTH + 4));
+				idx.read(off + IDX_HDR_LEN, idxdata[k]);
+			}
+		}
 	}
 
-	private PackedObjectLoader reader(final long objOffset, final byte[] ib)
+	private PackedObjectLoader reader(final long objOffset)
 			throws IOException {
 		long pos = objOffset;
 		int p = 0;
-
+		final byte[] ib = new byte[Constants.OBJECT_ID_LENGTH];
 		pack.readFully(pos, ib);
 		int c = ib[p++] & 0xff;
 		final int typeCode = (c >> 4) & 7;
@@ -239,23 +233,26 @@ public class PackFile {
 		return new WholePackedObjectLoader(this, pos, type, (int) size);
 	}
 
-	private long findOffset(final ObjectId objId, final byte[] tmpid)
-			throws IOException {
+	private long findOffset(final ObjectId objId) {
 		final int levelOne = objId.getFirstByte();
-		long high = idxHeader[levelOne];
-		long low = levelOne == 0 ? 0 : idxHeader[levelOne - 1];
-
+		byte[] data = idxdata[levelOne];
+		if (data == null)
+			return -1;
+		long high = data.length / (4 + Constants.OBJECT_ID_LENGTH);
+		long low = 0;
 		do {
 			final long mid = (low + high) / 2;
-			final long pos = IDX_HDR_LEN
-					+ ((4 + Constants.OBJECT_ID_LENGTH) * mid) + 4;
-			idx.readFully(pos, tmpid);
-			final int cmp = objId.compareTo(tmpid);
+			final long pos = ((4 + Constants.OBJECT_ID_LENGTH) * mid) + 4;
+			final int cmp = objId.compareTo(data, pos);
 			if (cmp < 0)
 				high = mid;
-			else if (cmp == 0)
-				return idx.readUInt32(pos - 4, tmpid);
-			else
+			else if (cmp == 0) {
+				int b0 = data[(int)pos-4] & 0xff;
+				int b1 = data[(int)pos-3] & 0xff;
+				int b2 = data[(int)pos-2] & 0xff;
+				int b3 = data[(int)pos-1] & 0xff;
+				return (((long)b0) << 24) | ( b1 << 16 ) | ( b2 << 8 ) | (b3); 
+			} else
 				low = mid + 1;
 		} while (low < high);
 		return -1;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 0f2a900..482f41d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -152,17 +152,9 @@ public class Repository {
 	public boolean hasObject(final ObjectId objectId) {
 		int k = packs.length;
 		if (k > 0) {
-			final byte[] tmp = new byte[Constants.OBJECT_ID_LENGTH];
 			do {
-				try {
-					if (packs[--k].hasObject(objectId, tmp))
-						return true;
-				} catch (IOException ioe) {
-					// This shouldn't happen unless the pack was corrupted
-					// after we opened it. We'll ignore the error as though
-					// the object does not exist in this pack.
-					//
-				}
+				if (packs[--k].hasObject(objectId))
+					return true;
 			} while (k > 0);
 		}
 		return toFile(objectId).isFile();
@@ -171,10 +163,9 @@ public class Repository {
 	public ObjectLoader openObject(final ObjectId id) throws IOException {
 		int k = packs.length;
 		if (k > 0) {
-			final byte[] tmp = new byte[Constants.OBJECT_ID_LENGTH];
 			do {
 				try {
-					final ObjectLoader ol = packs[--k].get(id, tmp);
+					final ObjectLoader ol = packs[--k].get(id);
 					if (ol != null)
 						return ol;
 				} catch (IOException ioe) {
@@ -185,7 +176,7 @@ public class Repository {
 					// time to collect and try once more.
 					try {
 						System.gc();
-						final ObjectLoader ol = packs[k].get(id, tmp);
+						final ObjectLoader ol = packs[k].get(id);
 						if (ol != null)
 							return ol;
 					} catch (IOException ioe2) {
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java
new file mode 100644
index 0000000..f98c6f7
--- /dev/null
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java
@@ -0,0 +1,170 @@
+/*
+ *  Copyright (C) 2006  Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License, version 2, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+public class ObjectIdMapTest extends TestCase {
+
+	ObjectId[] ids = new ObjectId[1000000];
+	
+	protected void setUp() throws Exception {
+		int b=0;
+		for (int i=0; i<ids.length; ++i) {
+			byte[] data = new byte[Constants.OBJECT_ID_LENGTH];
+			for (int j=0; j<Constants.OBJECT_ID_LENGTH; ++j)
+				data[j] = (byte) (b++^0xEE);
+			ids[i] = new ObjectId(data);
+		}
+	}
+
+	protected void tearDown() throws Exception {
+		ids = null; // avoid out of memory
+	}
+
+	public void testBoth() {
+		long d1=0;
+		long d2=0;
+		long d3=0;
+		long d4=0;
+		long d5=0;
+		long d6=0;
+
+		for (int j=0; j<64; ++j) {
+			int x = 
+				((j & 1)!=0  ? 1 : 0) |
+				((j & 2)!=0  ? 2 : 0) |
+				((j & 4)!=0  ? 16 : 0) |
+				((j & 8)!=0  ? 32 : 0) |
+				((j & 16)!=0 ? 4 : 0) |
+				((j & 32)!=0 ? 8 : 0);
+
+			if ((x&1) == 0) {
+				long t0 = System.currentTimeMillis();
+				
+				Map treeMap = new TreeMap();
+				for (int i=0; i<ids.length; ++i)
+					treeMap.put(ids[i],ids[i]);
+		
+				long t1 = System.currentTimeMillis();
+				d1 += t1-t0;
+			}
+			if ((x&2) == 0) {
+				long t0 = System.currentTimeMillis();
+				Map hashMap = new HashMap();
+				for (int i=0; i<ids.length; ++i)
+					hashMap.put(ids[i],ids[i]);
+				long t1 = System.currentTimeMillis();
+				d2 += t1-t0;
+			}
+			
+			if ((x&4) == 0) {
+				long t0= System.currentTimeMillis();
+	
+				Map levelMapWithTree = new ObjectIdMap(new TreeMap());
+				for (int i=0; i<ids.length; ++i)
+					levelMapWithTree.put(ids[i],ids[i]);
+	
+				long t1 = System.currentTimeMillis();
+				d3 += t1-t0;
+			}
+			
+			if ((x&8) == 0) {
+				long t0 = System.currentTimeMillis();
+				Map levelMapWithHash = new ObjectIdMap(new HashMap());
+				for (int i=0; i<ids.length; ++i)
+					levelMapWithHash.put(ids[i],ids[i]);
+		
+				long t1 = System.currentTimeMillis();
+	
+				d4 += t1-t0;
+			}
+
+			if ((x&16) == 0) {
+				long t0= System.currentTimeMillis();
+	
+				Map levelMapWithTreeAndSpecialCompare = new ObjectIdMap(new TreeMap(new Comparator() {
+				
+					public int compare(Object arg0, Object arg1) {
+						byte[] b0=((ObjectId)arg0).getBytes();
+						byte[] b1=((ObjectId)arg1).getBytes();
+						for (int i=1; i<Constants.OBJECT_ID_LENGTH; ++i) {
+							int a=b0[i]&0xff;
+							int b=b1[i]&0xff;
+							int c=a-b;
+							if (c!=0)
+								return c;
+						}
+						return 0;
+					}
+				
+				}));
+				for (int i=0; i<ids.length; ++i)
+					levelMapWithTreeAndSpecialCompare.put(ids[i],ids[i]);
+	
+				long t1 = System.currentTimeMillis();
+				d5 += t1-t0;
+			}
+			
+			if ((j&32) == 0) {
+				long t0= System.currentTimeMillis();
+	
+				Map levelMapWithTreeAndSpecialCompare = new ObjectIdMap(new TreeMap(new Comparator() {
+				
+					public int compare(Object arg0, Object arg1) {
+						return ((Comparable)arg0).compareTo(arg1);
+					}
+				
+				}));
+				for (int i=0; i<ids.length; ++i)
+					levelMapWithTreeAndSpecialCompare.put(ids[i],ids[i]);
+	
+				long t1 = System.currentTimeMillis();
+				d6 += t1-t0;
+			}
+		}
+		
+		System.out.println("TreeMap                              ="+d1);
+		System.out.println("HashMap                              ="+d2);
+		System.out.println("Partitioned TreeMap ObjectId.compare ="+d3);
+		System.out.println("Partitioned HashMap                  ="+d4);
+		System.out.println("Partitioned TreeMap enhanced compare ="+d5);
+		System.out.println("Partitioned TreeMap dummy    compare ="+d6);
+		assertEquals(d5*10/10000, d2*8/10000); // d5 is ~20% better
+	}
+
+	public void testFunc() {
+		Map treeMap = new TreeMap();
+		for (int i=0; i<ids.length/100; ++i)
+			treeMap.put(ids[i],ids[i]);
+		Map levelMapWithTree = new ObjectIdMap(new TreeMap());
+		for (int i=0; i<ids.length/100; ++i)
+			levelMapWithTree.put(ids[i],ids[i]);
+		
+		assertEquals(treeMap, levelMapWithTree);
+	}
+
+	public static void main(String[] args) {
+		TestRunner.run(ObjectIdMapTest.class);
+	}
+}
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
index 24f6b03..118415d 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
@@ -30,7 +30,7 @@ public class T0004_PackReader extends RepositoryTestCase {
 
 		id = new ObjectId("902d5476fa249b7abc9d84c611577a81381f0327");
 		pr = new PackFile(db, TEST_PACK);
-		or = pr.get(id, new byte[Constants.OBJECT_ID_LENGTH]);
+		or = pr.get(id);
 		assertNotNull(or);
 		assertEquals(id, or.getId());
 		assertEquals(Constants.TYPE_TREE, or.getType());

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 08/10] Use ObjectId[] instead of List for parents
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (6 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 07/10] Cache pack index fully Robin Rosenberg
@ 2007-05-07 21:29 ` Robin Rosenberg
  2007-05-07 21:30 ` [EGIT PATCH 09/10] Run history refresh in background Robin Rosenberg
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
  To: spearce; +Cc: git

This is more convenient to work with and slightly
faster and memory conserving, although the first
aspect is the most important thing.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../egit/core/internal/mapping/GitFileHistory.java |   23 ++++++++------
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    7 ++--
 .../internal/actions/GitCompareRevisionAction.java |    2 +
 .../src/org/spearce/jgit/lib/Commit.java           |   38 ++++++++++++++++++-----
 .../src/org/spearce/jgit/lib/ObjectWriter.java     |    7 ++--
 .../src/org/spearce/jgit/lib/Walker.java           |   11 +++----
 org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java |    8 ++--
 .../spearce/jgit/lib/T0005_ShallowSpeedTest.java   |   15 ++++-----
 .../org/spearce/jgit/lib/T0006_DeepSpeedTest.java  |    7 ++--
 9 files changed, 68 insertions(+), 50 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 71b29ce..4df98e6 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,13 +65,13 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 
 	public IFileRevision[] getContributors(IFileRevision revision) {
 		GitFileRevision grevision = (GitFileRevision) revision;
-		List parents = grevision.getCommit().getParentIds();
-		IFileRevision[] ret = new IFileRevision[parents.size()];
+		ObjectId[] parents = grevision.getCommit().getParentIds();
+		IFileRevision[] ret = new IFileRevision[parents.length];
 		Repository repository = getRepository();
-		for (int i = 0; i < parents.size(); ++i) {
+		for (int i = 0; i < parents.length; ++i) {
 			try {
 				ret[i] = new GitFileRevision(repository
-						.mapCommit((ObjectId) parents.get(i)), grevision
+						.mapCommit(parents[i]), grevision
 				.getResource(), -1);
 			} catch (IOException e) {
 				e.printStackTrace();
@@ -150,9 +150,9 @@ static class EclipseWalker extends Walker {
 			ObjectId id = repository.resolve("HEAD");
 			Commit current = repository.mapCommit(id);
 			if (repository.isStGitMode()) {
-				List parentIds = current.getParentIds();
-				if (parentIds != null && parentIds.size() > 0)
-					current = repository.mapCommit((ObjectId) parentIds.get(0));
+				ObjectId[] parentIds = current.getParentIds();
+				if (parentIds != null && parentIds.length > 0)
+					current = repository.mapCommit(parentIds[0]);
 				else {
 					revisions = new IFileRevision[0];
 					return;
@@ -264,9 +264,12 @@ static class EclipseWalker extends Walker {
 		List ret = new ArrayList(4);
 		for (int i = 0; i < revisions.length; ++i) {
 			Commit ref = ((GitFileRevision) revisions[i]).getCommit();
-			List parentIds = ref.getParentIds();
-			if (parentIds.contains(targetCommitId)) {
-				ret.add(revisions[i]);
+			ObjectId[] parentIds = ref.getParentIds();
+			for (int j = 0; j < parentIds.length; ++j) {
+				if (parentIds[j].equals(targetCommitId)) {
+					ret.add(revisions[i]);
+					break;
+				}
 			}
 		}
 		return (IFileRevision[]) ret.toArray(new IFileRevision[ret.size()]);
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 4b437a6..ec200e2 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
@@ -18,7 +18,6 @@ package org.spearce.egit.ui;
 
 import java.io.IOException;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
 import org.eclipse.compare.CompareConfiguration;
@@ -151,9 +150,9 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				RepositoryMapping repositoryMapping = provider.getData().getRepositoryMapping(project);
 				try {
 					if (selection2.length == 1 && hintShowDiffNow) {
-						List parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
-						if (parentIds.size() > 0) {
-							ObjectId parentId = (ObjectId)parentIds.get(0);
+						ObjectId[] parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
+						if (parentIds.length > 0) {
+							ObjectId parentId = parentIds[0];
 							Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
 							IFileRevision previous = new GitFileRevision(parent,
 									((GitFileRevision)selection2[0]).getResource(),
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
index d5780a5..6177e01 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
@@ -194,7 +194,7 @@ public class GitCompareRevisionAction extends BaseSelectionListenerAction {
 			IFileRevision rev2=(IFileRevision)selection.toArray()[1];
 			System.out.println("Compare "+rev1.getContentIdentifier()+" with "+rev2.getContentIdentifier());
 			if (rev1 instanceof GitFileRevision && rev2 instanceof GitFileRevision) {
-				ObjectId pid = (ObjectId) ((GitFileRevision)rev1).getCommit().getParentIds().get(0);
+				ObjectId pid = ((GitFileRevision)rev1).getCommit().getParentIds()[0];
 				if (pid.equals(((GitFileRevision)rev2).getCommit().getCommitId())) {
 					this.setText("Show commit diff");
 				} else {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
index f5cc6ec..d2cf3af 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
@@ -20,21 +20,21 @@ import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.spearce.jgit.errors.CorruptObjectException;
 import org.spearce.jgit.errors.MissingObjectException;
 
 public class Commit implements Treeish {
+	private static final ObjectId[] EMPTY_OBJECTID_LIST = new ObjectId[0];
+
 	private final Repository objdb;
 
 	private ObjectId commitId;
 
 	private ObjectId treeId;
 
-	private List parentIds;
-
+	private ObjectId[] parentIds;
+	
 	private PersonIdent author;
 
 	private PersonIdent committer;
@@ -49,22 +49,42 @@ public class Commit implements Treeish {
 
 	public Commit(final Repository db) {
 		objdb = db;
-		parentIds = new ArrayList(2);
+		parentIds = EMPTY_OBJECTID_LIST;
 	}
 
 	public Commit(final Repository db, final ObjectId id, final byte[] raw) {
 		objdb = db;
 		commitId = id;
 		treeId = ObjectId.fromString(raw, 5);
-		parentIds = new ArrayList(2);
+		parentIds = new ObjectId[1];
+		int np=0;
 		int rawPtr = 46;
 		for (;;) {
 			if (raw[rawPtr] != 'p')
 				break;
-			parentIds.add(ObjectId.fromString(raw, rawPtr + 7));
+			if (np == 0) {
+				parentIds[np++] = ObjectId.fromString(raw, rawPtr + 7);
+			} else if (np == 1) {
+				parentIds = new ObjectId[] { parentIds[0], ObjectId.fromString(raw, rawPtr + 7) };
+			} else {
+				if (parentIds.length < np) {
+					ObjectId[] old = parentIds;
+					parentIds = new ObjectId[parentIds.length+32];
+					for (int i=0; i<np; ++i)
+						parentIds[i] = old[i];
+				}
+				parentIds[np++] = ObjectId.fromString(raw, rawPtr + 7);
+			}
 			rawPtr += 48;
 		}
-
+		if (np != parentIds.length) {
+			ObjectId[] old = parentIds;
+			parentIds = new ObjectId[np];
+			for (int i=0; i<np; ++i)
+				parentIds[i] = old[i];
+		} else
+			if (np == 0)
+				parentIds = EMPTY_OBJECTID_LIST;
 		this.raw = raw;
 	}
 
@@ -121,7 +141,7 @@ public class Commit implements Treeish {
 		committer = c;
 	}
 
-	public List getParentIds() {
+	public ObjectId[] getParentIds() {
 		return parentIds;
 	}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
index f9f2bde..b947a80 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.security.MessageDigest;
-import java.util.Iterator;
 import java.util.zip.Deflater;
 import java.util.zip.DeflaterOutputStream;
 
@@ -121,11 +120,11 @@ public class ObjectWriter {
 		c.getTreeId().copyTo(os);
 		os.write('\n');
 
-		final Iterator i = c.getParentIds().iterator();
-		while (i.hasNext()) {
+		ObjectId[] ps = c.getParentIds();
+		for (int i=0; i<ps.length; ++i) {
 			os.write(hparent);
 			os.write(' ');
-			((ObjectId) i.next()).copyTo(os);
+			ps[i].copyTo(os);
 			os.write('\n');
 		}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
index 2928e1d..86c8a1e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -8,7 +8,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 
 public abstract class Walker {
 	private String[] relativeResourceName;
@@ -98,10 +97,10 @@ public abstract class Walker {
 
 			// TODO: we may need to list more revisions when traversing
 			// branches
-			List parents = current.getParentIds();
+			ObjectId[] parents = current.getParentIds();
 			if (!followMainOnly) {
-				for (int i = 1; i < parents.size(); ++i) {
-					ObjectId mergeParentId = (ObjectId) parents.get(i);
+				for (int i = 1; i < parents.length; ++i) {
+					ObjectId mergeParentId = parents[i];
 					Commit mergeParent;
 					try {
 						mergeParent = repository.mapCommit(mergeParentId);
@@ -115,8 +114,8 @@ public abstract class Walker {
 					}
 				}
 			}
-			if (parents.size() > 0) {
-				ObjectId parentId = (ObjectId) parents.get(0);
+			if (parents.length > 0) {
+				ObjectId parentId = parents[0];
 				try {
 					current = repository.mapCommit(parentId);
 				} catch (IOException e) {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java b/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
index 8ba9182..73bf556 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
@@ -2,9 +2,8 @@ package org.spearce.jgit.pgm;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Iterator;
-
 import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.Repository;
 
 public class Log {
@@ -13,8 +12,9 @@ public class Log {
 		Commit commit = db.mapCommit(args[0]);
 		System.out.println("commit " + commit.getCommitId());
 		System.out.println("tree " + commit.getTreeId());
-		for (Iterator ci = commit.getParentIds().iterator(); ci.hasNext();) {
-			System.out.println("parent " + ci.next());
+		ObjectId[] ps=commit.getParentIds();
+		for (int ci=0; ci<ps.length; ++ci) {
+			System.out.println("parent " + ps[ci]);
 		}
 		System.out.println("author " + commit.getAuthor());
 		System.out.println();
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
index 36e74ae..b598a13 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
@@ -18,7 +18,6 @@ package org.spearce.jgit.lib;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
 
 import junit.textui.TestRunner;
 
@@ -35,9 +34,9 @@ public class T0005_ShallowSpeedTest extends SpeedTestBase {
 		int n = 1;
 		do {
 			// System.out.println("commit="+commit.getCommitId());
-			List parent = commit.getParentIds();
-			if (parent.size() > 0) {
-				ObjectId parentId = (ObjectId) parent.get(0);
+			ObjectId[] parents = commit.getParentIds();
+			if (parents.length > 0) {
+				ObjectId parentId = parents[0];
 				commit = db.mapCommit(parentId);
 				commit.getCommitId().toString();
 				++n;
@@ -52,13 +51,13 @@ public class T0005_ShallowSpeedTest extends SpeedTestBase {
 		System.out.println("jgit="+time);
 		// ~0.750s (hot cache), ok
 		/*
-native=1748
-jgit=774
+native=1795
+jgit=722
 		 */
 		// native git seems to run SLOWER than jgit here, at roughly half the speed
 		// creating the git process is not the issue here, btw.
-		long factor10 = (nativeTime*110/time+50)/100;
-		assertEquals(2, factor10);
+		long factor10 = (nativeTime*150/time+50)/100;
+		assertEquals(3, factor10);
 	}
 
 	public static void main(String[] args) {
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
index b4ae4b8..244792c 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
@@ -18,7 +18,6 @@ package org.spearce.jgit.lib;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
 
 import junit.textui.TestRunner;
 
@@ -35,9 +34,9 @@ public class T0006_DeepSpeedTest extends SpeedTestBase {
 		int n = 1;
 		do {
 			// System.out.println("commit="+commit.getCommitId());
-			List parent = commit.getParentIds();
-			if (parent.size() > 0) {
-				ObjectId parentId = (ObjectId) parent.get(0);
+			ObjectId[] parents = commit.getParentIds();
+			if (parents.length > 0) {
+				ObjectId parentId = parents[0];
 				commit = db.mapCommit(parentId);
 				TreeEntry m = commit.getTree().findBlobMember("net/netfilter/nf_queue.c");
 				if (m != null)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 09/10] Run history refresh in background
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (7 preceding siblings ...)
  2007-05-07 21:29 ` [EGIT PATCH 08/10] Use ObjectId[] instead of List for parents Robin Rosenberg
@ 2007-05-07 21:30 ` Robin Rosenberg
  2007-05-07 21:30 ` [EGIT PATCH 10/10] Enable a tooltip in the history view Robin Rosenberg
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:30 UTC (permalink / raw)
  To: spearce; +Cc: git

Don't wait in the UI for history refresh. If a history is being
computed when a new refresh is requested, abort the first one and
start a new history computation.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../egit/core/internal/mapping/GitFileHistory.java |   40 ++++++++-----
 .../internal/mapping/GitFileHistoryProvider.java   |    2 -
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |   73 +++++++++++++++++------
 .../src/org/spearce/jgit/lib/Walker.java           |    4 +
 .../tst/org/spearce/jgit/lib/T0007_WalkerTest.java |    4 +
 5 files changed, 86 insertions(+), 37 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 4df98e6..9cf9107 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
@@ -27,6 +27,7 @@ import java.util.List;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.team.core.RepositoryProvider;
 import org.eclipse.team.core.history.IFileHistoryProvider;
 import org.eclipse.team.core.history.IFileRevision;
@@ -52,7 +53,7 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 
 	private IFileRevision[] revisions;
 
-	public GitFileHistory(IResource resource, int flags) {
+	public GitFileHistory(IResource resource, int flags, IProgressMonitor monitor) {
 		this.resource = resource;
 		this.flags = flags;
 		String prefix = getRepositoryMapping().getSubset();
@@ -61,6 +62,15 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 		relativeResourceName = new String[prefixSegments.length + resourceSegments.length];
 		System.arraycopy(prefixSegments, 0, relativeResourceName, 0, prefixSegments.length);
 		System.arraycopy(resourceSegments, 0, relativeResourceName, prefixSegments.length, resourceSegments.length);
+		if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0) {
+			findSingleRevision(monitor);
+		} else {
+			try {
+				findRevisions(monitor);
+			} catch (IOException e) {
+				throw new Error(e);
+			}
+		}
 	}
 
 	public IFileRevision[] getContributors(IFileRevision revision) {
@@ -111,28 +121,24 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 
 static class EclipseWalker extends Walker {
 	IResource resource;
-	
-	EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId) {
+	private final IProgressMonitor monitor;
+
+	EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId, IProgressMonitor monitor) {
 		super(repository, start, relativeResourceName, leafIsBlob, followMainOnly, lastActiveDiffId);
 		this.resource = resource;
+		this.monitor = monitor;
 	}
 
 	protected void collect(Collection ret,Commit commit, int count) {
 		ret.add(new GitFileRevision(commit, resource, count));		
 	}
-	
+
+	public boolean isCancelled() {
+		return monitor.isCanceled();
+	}
 };
 
 	public IFileRevision[] getFileRevisions() {
-		if (revisions == null)
-			if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0)
-				findSingleRevision();
-			else
-				try {
-					findRevisions();
-				} catch (IOException e) {
-					throw new Error(e);
-				}
 		return revisions;
 	}
 
@@ -143,8 +149,9 @@ static class EclipseWalker extends Walker {
 	 * return the revision prior to the topmost patch, be it another patch or a
 	 * normal Git Commit. This is the revision in HEAD^. Otherwise we return the
 	 * revision in HEAD.
+	 * @param monitor 
 	 */
-	private void findSingleRevision() {
+	private void findSingleRevision(IProgressMonitor monitor) {
 		try {
 			Repository repository = getRepository();
 			ObjectId id = repository.resolve("HEAD");
@@ -177,7 +184,7 @@ static class EclipseWalker extends Walker {
 		}
 	}
 
-	private void findRevisions() throws IOException {
+	private void findRevisions(IProgressMonitor monitor) throws IOException {
 		RepositoryProvider provider = RepositoryProvider.getProvider(resource
 				.getProject());
 		if (provider instanceof GitProvider) {
@@ -203,7 +210,8 @@ static class EclipseWalker extends Walker {
 					resource.getType() == IResource.FILE, 
 					resource, 
 					(flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0,
-					activeDiffLeafId);
+					activeDiffLeafId,
+					monitor);
 			Collection githistory = walker.collectHistory();
 			if (githistory.size() >0) {
 				if (resource.getType()==IResource.FILE) {
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 2d1050f..7ff1ef5 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
@@ -31,7 +31,7 @@ public class GitFileHistoryProvider extends FileHistoryProvider implements
 	public IFileHistory getFileHistoryFor(IResource resource, int flags,
 			IProgressMonitor monitor) {
 		// TODO: implement flags
-		return new GitFileHistory(resource, flags); // TODO: implement flags
+		return new GitFileHistory(resource, flags, monitor); // TODO: implement flags
 	}
 
 	public IFileRevision getWorkspaceFileRevision(IResource resource) {
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 ec200e2..57fefcc 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
@@ -29,6 +29,10 @@ import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
@@ -322,21 +326,22 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 
 	private Map appliedPatches;
 
-	class GitHistoryContentProvider implements ITreeContentProvider,
-			ILazyTreeContentProvider {
+	class HistoryRefreshJob extends Job {
 
-		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-			if (newInput == null)
-				return;
-			System.out.println("inputChanged(" + viewer + "," + oldInput + ","
-					+ newInput);
+		public HistoryRefreshJob(String name) {
+			super(name);
+		}
+
+		protected IStatus run(IProgressMonitor monitor) {
+			monitor = new NullProgressMonitor();
+			monitor.beginTask("UpdateHistory", IProgressMonitor.UNKNOWN);
 			IProject project = ((IResource) getInput()).getProject();
 			RepositoryProvider provider = RepositoryProvider
 					.getProvider(project);
 			RepositoryMapping repositoryMapping = ((GitProvider)provider).getData().getRepositoryMapping(project);
+			Map newappliedPatches = null;
 			try {
-				appliedPatches = null;
-				appliedPatches = repositoryMapping.getRepository().getAppliedPatches();
+				newappliedPatches = repositoryMapping.getRepository().getAppliedPatches();
 			} catch (IOException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
@@ -345,18 +350,48 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 					.getFileHistoryProvider();
 			IFileHistory fileHistoryFor = fileHistoryProvider
 					.getFileHistoryFor((IResource) getInput(),
-							IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, null/* monitor */);
+							IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, monitor);
 			fileRevisions = fileHistoryFor.getFileRevisions();
-			tree.removeAll();
-			tree.setItemCount(fileRevisions.length);
-			tree.setData(fileRevisions);
-			tree.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
-			System.out.println("inputchanged, invoking refresh");
-			viewer.refresh();
+			
+			final Map fnewappliedPatches = newappliedPatches; 
+			tree.getDisplay().asyncExec(new Runnable() {
+			
+				public void run() {
+					tree.removeAll();
+					tree.setItemCount(fileRevisions.length);
+					tree.setData(fileRevisions);
+					tree.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
+					System.out.println("inputchanged, invoking refresh");
+					viewer.refresh();
+					appliedPatches = fnewappliedPatches;
+					done(Status.OK_STATUS);
+				}
+			
+			});
+			return Status.OK_STATUS;
+		}
+		
+	}
+
+	HistoryRefreshJob historyRefreshJob = new HistoryRefreshJob("Git history refresh");
+	
+	class GitHistoryContentProvider implements ITreeContentProvider,
+			ILazyTreeContentProvider {
+
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			if (newInput == null)
+				return;
+			System.out.println(new Date()+"inputChanged(" + viewer + "," + oldInput + ","
+					+ newInput);
+			if (historyRefreshJob.cancel()) {
+				System.out.println("rescheduling");
+				historyRefreshJob.schedule();
+			} else {
+				System.out.println("failed to cancel?");
+			}
 		}
 
 		public void dispose() {
-			// TODO Auto-generated method stub
 		}
 
 		public Object[] getElements(Object inputElement) {
@@ -380,12 +415,12 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		}
 
 		public void updateChildCount(Object element, int currentChildCount) {
-			viewer.setChildCount(element, fileRevisions.length);
+			viewer.setChildCount(element, fileRevisions!=null ? fileRevisions.length : 0);
 		}
 
 		public void updateElement(Object parent, int index) {
 			System.out.println("updateElement("+parent+","+index);
-			viewer.replace(parent, index, fileRevisions[index]);
+			viewer.replace(parent, index, fileRevisions!=null ? fileRevisions[index] : null);
 		}
 	}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
index 86c8a1e..3c33274 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -17,6 +17,8 @@ public abstract class Walker {
 	private ObjectId activeDiffLeafId;
 	private final Commit start;
 
+	protected abstract boolean isCancelled();
+	
 	protected abstract void collect(Collection ret,Commit commit, int count);
 
 	protected Walker(Repository repostory, Commit start, String[] relativeResourceName,boolean leafIsBlob,boolean followMainOnly, ObjectId activeDiffLeafId) {
@@ -126,7 +128,7 @@ public abstract class Walker {
 				current = null;
 			if (count>=0)
 				count++;
-		} while (current != null);
+		} while (current != null && !isCancelled());
 
 		return ret;
 	}
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
index 82f0623..a41d707 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
@@ -42,6 +42,10 @@ public class T0007_WalkerTest extends SpeedTestBase {
 				System.out.println("Got: "+count+" "+commit.getCommitId());
 				ret.add(commit);
 			}
+
+			protected boolean isCancelled() {
+				return false;
+			}
 		
 		};
 		Commit[] history = (Commit[])walker.collectHistory().toArray(new Commit[0]);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [EGIT PATCH 10/10] Enable a tooltip in the history view
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (8 preceding siblings ...)
  2007-05-07 21:30 ` [EGIT PATCH 09/10] Run history refresh in background Robin Rosenberg
@ 2007-05-07 21:30 ` Robin Rosenberg
  2007-05-07 21:35 ` Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches) Grzegorz Kulewski
  2007-05-08  3:24 ` [EGIT 00/10] This weeks Eclipse patches Shawn O. Pearce
  11 siblings, 0 replies; 14+ messages in thread
From: Robin Rosenberg @ 2007-05-07 21:30 UTC (permalink / raw)
  To: spearce; +Cc: git

This tooltip show the comment in full rather than the first line only.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../src/org/spearce/egit/ui/GitHistoryPage.java    |   27 +++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

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 57fefcc..e5d92fe 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
@@ -48,9 +48,11 @@ import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
@@ -136,6 +138,31 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		
 		});
 
+		tree.addMouseMoveListener(new MouseMoveListener() {
+			TreeItem lastItem;
+			public void mouseMove(MouseEvent e) {
+				TreeItem item = tree.getItem(new Point(e.x,e.y));
+				if (item != null && item!=lastItem) {
+					IFileRevision rev = (IFileRevision) item.getData();
+					String commitStr=null;
+					if (appliedPatches!=null) {
+						String id = rev.getContentIdentifier();
+						if (!id.equals("Workspace")) {
+							StGitPatch patch = (StGitPatch) appliedPatches.get(new ObjectId(id));
+							if (patch!=null)
+								commitStr = "Patch: "+patch.getName();
+						} else {
+							commitStr = "Workspace:";
+						}
+					}
+					if (commitStr == null)
+						commitStr = "Commit: "+rev.getContentIdentifier();
+					tree.setToolTipText(commitStr+"\nAuthor:\t"+rev.getAuthor()+"\nDate:\t"+new Date(rev.getTimestamp())+"\n\n"+rev.getComment());
+				}
+				lastItem = item;
+			}
+		});
+
 		tree.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
 				// update the current

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches)
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (9 preceding siblings ...)
  2007-05-07 21:30 ` [EGIT PATCH 10/10] Enable a tooltip in the history view Robin Rosenberg
@ 2007-05-07 21:35 ` Grzegorz Kulewski
  2007-05-08  2:07   ` Shawn O. Pearce
  2007-05-08  3:24 ` [EGIT 00/10] This weeks Eclipse patches Shawn O. Pearce
  11 siblings, 1 reply; 14+ messages in thread
From: Grzegorz Kulewski @ 2007-05-07 21:35 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: spearce, git

On Mon, 7 May 2007, Robin Rosenberg wrote:
> A random collection of improvements to the Eclipse
> plugin.

Hi,

I wanted to ask about current status of Git-Eclipse support. Is this 
plugin able to actually do anything or not? What works and what does not? 
Can it be used by developers using Git? Or maybe git-svn or git-cvsserver 
are better?

If it it not usable at the moment do you have any idea when it may be 
usable? I know several developers really waiting for such support even 
early or beta quality.


Thanks,

Grzegorz Kulewski

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches)
  2007-05-07 21:35 ` Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches) Grzegorz Kulewski
@ 2007-05-08  2:07   ` Shawn O. Pearce
  0 siblings, 0 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2007-05-08  2:07 UTC (permalink / raw)
  To: Grzegorz Kulewski; +Cc: Robin Rosenberg, git

Grzegorz Kulewski <kangur@polcom.net> wrote:
> I wanted to ask about current status of Git-Eclipse support. Is this 
> plugin able to actually do anything or not? What works and what does not? 
> Can it be used by developers using Git? Or maybe git-svn or git-cvsserver 
> are better?

There's no support for committing through Eclipse yet, let alone
doing things like creating new branches or switching branches.

But Robin has done a lot of work on the status and history viewing
tools, to the point that you can use the QuickDiff feature in
Eclipse to see which parts of a file you have recently modified
(but not committed), which files/directories are modified in the
Navigator, and view the "git shortlog" for the currently selected
file/directory.

> If it it not usable at the moment do you have any idea when it may be 
> usable? I know several developers really waiting for such support even 
> early or beta quality.

I would say its *very* early alpha.  It could cause your Eclipse
workbench to run out of memory, and crash, especially on large
projects.  It also doesn't have that many features yet.  ;-)

-- 
Shawn.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [EGIT 00/10] This weeks Eclipse patches
  2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
                   ` (10 preceding siblings ...)
  2007-05-07 21:35 ` Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches) Grzegorz Kulewski
@ 2007-05-08  3:24 ` Shawn O. Pearce
  11 siblings, 0 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2007-05-08  3:24 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> A random collection of improvements to the Eclipse
> plugin.

Thanks, applied, pushed to usual locations.
 
-- 
Shawn.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-05-08  3:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-07 21:29 [EGIT 00/10] This weeks Eclipse patches Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 02/10] Recursion and update of all elements regardless of need Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 03/10] Update compare window immediately Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 04/10] Bug: Do not crash when showing diff for first version of a file Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 05/10] Speed up ObjectId a little Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 06/10] Create a generic history walker Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 07/10] Cache pack index fully Robin Rosenberg
2007-05-07 21:29 ` [EGIT PATCH 08/10] Use ObjectId[] instead of List for parents Robin Rosenberg
2007-05-07 21:30 ` [EGIT PATCH 09/10] Run history refresh in background Robin Rosenberg
2007-05-07 21:30 ` [EGIT PATCH 10/10] Enable a tooltip in the history view Robin Rosenberg
2007-05-07 21:35 ` Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches) Grzegorz Kulewski
2007-05-08  2:07   ` Shawn O. Pearce
2007-05-08  3:24 ` [EGIT 00/10] This weeks Eclipse patches Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).