git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin
@ 2007-03-11 18:15 Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 01/10] Git history refresh problem Robin Rosenberg
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

Here is a mix of bug fixes and performance improvements. The most
important ones are that the history panel now shows the right
history (yea, I'm an SWT/JFace n00b so there may be more suble bugs
there). Actually, now that I come to think of it; the rows in the
history window sometimes get the wrong height. The workaround is
to press ALT-F4 and then cancel. 

The other big thing is that Eclipse now caches commits so browsing
the resorces updates the history view immediately instead of an
annoying second or two later, provided the Link with Editor button
is pushed.

As for JDK, I recommend JDK 1.5.11 or JDK 1.6 for running because
of improvements and bug fixes made by Sun wrt GC and memory mapping.

-- robin

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

* [EGIT PATCH 01/10] Git history refresh problem
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 02/10] Support commit encoding header Robin Rosenberg
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

It seems the history window often lags one event behind.

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

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

 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    6 +++++-
 1 files changed, 5 insertions(+), 1 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 2a5fa98..d1591f0 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
@@ -242,9 +242,13 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 					.getFileHistoryFor((IResource) getInput(),
 							IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, null/* monitor */);
 			fileRevisions = fileHistoryFor.getFileRevisions();
-			tree.setData(fileRevisions);
+			tree.clearAll(true);
 			tree.setItemCount(fileRevisions.length);
+			tree.setData(fileRevisions);
+			System.out.println("inputchanged, invoking refresh");
 			viewer.refresh();
+			tree.getParent().layout();
+			tree.getParent().getParent().layout();
 		}
 
 		public void dispose() {

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

* [EGIT PATCH 02/10] Support commit encoding header
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 01/10] Git history refresh problem Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 03/10] Avoid a nullpointerexception on shutdown Robin Rosenberg
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

Commit objects may contain an encoding, supposedly meant to
indicated the encoding used for that particular commt.

This is the last header line before the comment as far as I know.

Unfortunately the encoding header only reflects a setting in the
config file, so it is most likely to be wrong by default unless
you are on a UTF-8 platform (in which case the header isn't really
needed). Later on we'll have to decode that more intelligently. For
now we make an attempt to decode according to the setting if present,
otherwise we use the platform default.

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

 .../src/org/spearce/jgit/lib/Commit.java           |   55 +++++++++++++++++------
 .../src/org/spearce/jgit/lib/ObjectWriter.java     |   11 ++++-
 .../tst/org/spearce/jgit/lib/T0003_Basic.java      |   32 +++++++++++++
 3 files changed, 82 insertions(+), 16 deletions(-)

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 d1ef5de..1b644dd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
@@ -16,10 +16,10 @@
  */
 package org.spearce.jgit.lib;
 
-import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
 import java.io.IOException;
-import java.io.InputStreamReader;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -45,6 +45,8 @@ public class Commit implements Treeish {
 
 	private byte[] raw;
 
+	private Charset encoding;
+
 	public Commit(final Repository db) {
 		objdb = db;
 		parentIds = new ArrayList(2);
@@ -132,8 +134,7 @@ public class Commit implements Treeish {
 		// FIXME: handle I/O errors
 		if (raw != null) {
 			try {
-				BufferedReader br = new BufferedReader(new InputStreamReader(
-						new ByteArrayInputStream(raw)));
+				DataInputStream br = new DataInputStream(new ByteArrayInputStream(raw));
 				String n = br.readLine();
 				if (n == null || !n.startsWith("tree ")) {
 					throw new CorruptObjectException(commitId, "no tree");
@@ -144,24 +145,33 @@ public class Commit implements Treeish {
 				if (n == null || !n.startsWith("author ")) {
 					throw new CorruptObjectException(commitId, "no author");
 				}
-				author = new PersonIdent(n.substring("author ".length()));
+				String rawAuthor = n.substring("author ".length());
 				n = br.readLine();
 				if (n == null || !n.startsWith("committer ")) {
 					throw new CorruptObjectException(commitId, "no committer");
 				}
-				committer = new PersonIdent(n.substring("committer ".length()));
+				String rawCommitter = n.substring("committer ".length());
 				n = br.readLine();
-				if (n == null || !n.equals("")) {
-					throw new CorruptObjectException(commitId,
-							"malformed header");
+				if (n != null && n.startsWith(	"encoding"))
+					encoding = Charset.forName(n.substring("encoding ".length()));
+				else
+					if (n == null || !n.equals("")) {
+						throw new CorruptObjectException(commitId,
+								"malformed header:"+n);
 				}
-				StringBuffer tempMessage = new StringBuffer();
-				char[] readBuf = new char[2048];
-				int readLen;
-				while ((readLen = br.read(readBuf)) > 0) {
-					tempMessage.append(readBuf, 0, readLen);
+				byte[] readBuf = new byte[br.available()]; // in-memory stream so this is all bytes left
+				br.read(readBuf);
+				if (encoding != null) {
+					// TODO: this isn't reliable so we need to guess the encoding from the actual content
+					author = new PersonIdent(new String(rawAuthor.getBytes(),encoding));
+					committer = new PersonIdent(new String(rawCommitter.getBytes(),encoding));
+					message = new String(readBuf,encoding);
+				} else {
+					// TODO: use config setting / platform / ascii / iso-latin
+					author = new PersonIdent(new String(rawAuthor.getBytes()));
+					committer = new PersonIdent(new String(rawCommitter.getBytes()));
+					message = new String(readBuf);
 				}
-				message = tempMessage.toString();
 			} catch (IOException e) {
 				e.printStackTrace();
 			} finally {
@@ -183,4 +193,19 @@ public class Commit implements Treeish {
 	public String toString() {
 		return "Commit[" + getCommitId() + " " + getAuthor() + "]";
 	}
+
+	public void setEncoding(String e) {
+		encoding = Charset.forName(e);
+	}
+
+	public void setEncoding(Charset e) {
+		encoding = e;
+	}
+
+	public String getEncoding() {
+		if (encoding != null)
+			return encoding.name();
+		else
+			return null;
+	}
 }
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 667b569..a88fd95 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
@@ -108,8 +108,11 @@ public class ObjectWriter {
 
 	public ObjectId writeCommit(final Commit c) throws IOException {
 		final ByteArrayOutputStream os = new ByteArrayOutputStream();
+		String encoding = c.getEncoding();
+		if (encoding == null)
+			encoding = Constants.CHARACTER_ENCODING;
 		final OutputStreamWriter w = new OutputStreamWriter(os,
-				Constants.CHARACTER_ENCODING);
+				encoding);
 
 		w.write("tree ");
 		c.getTreeId().copyTo(w);
@@ -130,6 +133,12 @@ public class ObjectWriter {
 		w.write(c.getCommitter().toExternalString());
 		w.write('\n');
 
+		if (!encoding.equals("UTF-8")) {
+			w.write("encoding ");
+			w.write(encoding);
+			w.write('\n');
+		}
+		
 		w.write('\n');
 		w.write(c.getMessage());
 		w.close();
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0003_Basic.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0003_Basic.java
index 9e6f805..9c807f9 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0003_Basic.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0003_Basic.java
@@ -21,6 +21,8 @@ import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.Date;
+import java.util.TimeZone;
 
 public class T0003_Basic extends RepositoryTestCase {
 	public void test001_Initalize() {
@@ -385,4 +387,34 @@ public class T0003_Basic extends RepositoryTestCase {
 		assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.getAuthor());
 		assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().toString());
 	}
+	
+	public void test023_createCommitNonAscii() throws IOException {
+		final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
+		final Tree almostEmptyTree = new Tree(db);
+		almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
+		final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
+		Commit commit = new Commit(db);
+		commit.setTreeId(almostEmptyTreeId);
+		commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",new Date(1900,0,1), TimeZone.getTimeZone("CET")));
+		commit.setCommitter(new PersonIdent("Joe Hacker","joe2@example.com",new Date(1900,0,1), TimeZone.getTimeZone("CET")));
+		commit.setEncoding("UTF-8");
+		commit.setMessage("\u00dcbergeeks");
+		ObjectId cid = new ObjectWriter(db).writeCommit(commit);
+		assertEquals("ed63583834b8a627474ee9f9330434ef37a04825", cid.toString());
+	}
+
+	public void test024_createCommitNonAscii() throws IOException {
+		final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
+		final Tree almostEmptyTree = new Tree(db);
+		almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
+		final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
+		Commit commit = new Commit(db);
+		commit.setTreeId(almostEmptyTreeId);
+		commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",new Date(1900,0,1), TimeZone.getTimeZone("CET")));
+		commit.setCommitter(new PersonIdent("Joe Hacker","joe2@example.com",new Date(1900,0,1), TimeZone.getTimeZone("CET")));
+		commit.setEncoding("ISO-8859-1");
+		commit.setMessage("\u00dcbergeeks");
+		ObjectId cid = new ObjectWriter(db).writeCommit(commit);
+		assertEquals("afc8532038e7220179127b7e96acf534486798ce", cid.toString());
+	}
 }

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

* [EGIT PATCH 03/10] Avoid a nullpointerexception on shutdown
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 01/10] Git history refresh problem Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 02/10] Support commit encoding header Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 04/10] Speed up history by comparing tree hashes Robin Rosenberg
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

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

 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    2 ++
 1 files changed, 2 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 d1591f0..0e53036 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
@@ -232,6 +232,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 			ILazyTreeContentProvider {
 
 		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			if (newInput == null)
+				return;
 			System.out.println("inputChanged(" + viewer + "," + oldInput + ","
 					+ newInput);
 			RepositoryProvider provider = RepositoryProvider

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

* [EGIT PATCH 04/10] Speed up history by comparing tree hashes.
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (2 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 03/10] Avoid a nullpointerexception on shutdown Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 05/10] Cache commits Robin Rosenberg
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

Instead of looking up full path name all the time we split the
path name of the resource we are looking at and compare hashed
at each level.

The performance improvement isn't huge since most of the work
is reading commits.

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

 .../egit/core/internal/mapping/GitFileHistory.java |   79 +++++++++++++++--------
 .../src/org/spearce/jgit/lib/ObjectId.java         |    6 ++
 2 files changed, 58 insertions(+), 27 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 163278d..6c40bb0 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
@@ -18,6 +18,7 @@ package org.spearce.egit.core.internal.mapping;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
@@ -34,13 +35,14 @@ import org.spearce.egit.core.project.RepositoryMapping;
 import org.spearce.jgit.lib.Commit;
 import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
 
 public class GitFileHistory extends FileHistory {
 
 	private final IResource resource;
 
-	private final String relativeResourceName;
+	private final String[] relativeResourceName;
 
 	private final int flags;
 
@@ -50,12 +52,11 @@ public class GitFileHistory extends FileHistory {
 		this.resource = resource;
 		this.flags = flags;
 		String prefix = getRepositoryMapping().getSubset();
-		if (prefix != null)
-			prefix = prefix + "/";
-		else
-			prefix = "";
-		relativeResourceName = prefix
-				+ resource.getProjectRelativePath().toString();
+		String[] prefixSegments = prefix!=null ? prefix.split("/") : new String[0];
+		String[] resourceSegments = resource.getProjectRelativePath().segments(); 
+		relativeResourceName = new String[prefixSegments.length + resourceSegments.length];
+		System.arraycopy(prefixSegments, 0, relativeResourceName, 0, prefixSegments.length);
+		System.arraycopy(resourceSegments, 0, relativeResourceName, prefixSegments.length, resourceSegments.length);
 	}
 
 	public IFileRevision[] getContributors(IFileRevision revision) {
@@ -105,7 +106,9 @@ public class GitFileHistory extends FileHistory {
 		try {
 			ObjectId id = repository.resolve("HEAD");
 			Commit commit = repository.mapCommit(id);
-			return collectHistory(new ObjectId(ObjectId.toString(null)),
+			ObjectId[] initialResourceHash = new ObjectId[relativeResourceName.length];
+			Arrays.fill(initialResourceHash, ObjectId.zeroId());
+			return collectHistory(initialResourceHash, null,
 					repository, commit);
 		} catch (IOException e) {
 			e.printStackTrace();
@@ -113,29 +116,49 @@ public class GitFileHistory extends FileHistory {
 		}
 	}
 
-	private Collection collectHistory(ObjectId lastResourceHash,
-			Repository repository, Commit top) {
+	private Collection collectHistory(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;
-			try {
-				currentEntry = current.getTree().findMember(
-						relativeResourceName);
-			} catch (IOException e1) {
-				e1.printStackTrace();
-				return ret;
+			TreeEntry currentEntry = lastEntry;
+			ObjectId[] currentResourceHash = new ObjectId[lastResourceHash.length];
+			Tree t = current.getTree();
+			for (int i = 0; i < currentResourceHash.length; ++i) {
+				TreeEntry m = t.findMember(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();
+					}
+				}
 			}
-			ObjectId currentResourceHash;
-			if (currentEntry == null)
-				currentResourceHash = new ObjectId(ObjectId.toString(null));
-			else
-				currentResourceHash = currentEntry.getId();
-
-			if (!currentResourceHash.equals(lastResourceHash))
+			
+			if (!currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
 				ret.add(new GitFileRevision(previous, resource));
 
 			lastResourceHash = currentResourceHash;
@@ -150,7 +173,7 @@ public class GitFileHistory extends FileHistory {
 					Commit mergeParent;
 					try {
 						mergeParent = repository.mapCommit(mergeParentId);
-						ret.addAll(collectHistory(lastResourceHash, repository,
+						ret.addAll(collectHistory(lastResourceHash, currentEntry, repository, 
 								mergeParent));
 						// TODO: this gets us a lot of duplicates that we need
 						// to filter out
@@ -208,8 +231,10 @@ public class GitFileHistory extends FileHistory {
 					return;
 				}
 			}
-			TreeEntry currentEntry = current.getTree().findMember(
-					relativeResourceName);
+			TreeEntry currentEntry = current.getTree();
+			for (int i=0; i < relativeResourceName.length && currentEntry != null; ++i) {
+				((Tree)currentEntry).findMember(relativeResourceName[i]);
+			}
 			if (currentEntry != null)
 				revisions = new IFileRevision[] { new GitFileRevision(current,
 						resource) };
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 38fefe2..9e62424 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -30,6 +30,10 @@ public class ObjectId implements Comparable {
 		ZEROID_STR = ZEROID.toString();
 	}
 
+	public static ObjectId zeroId() {
+		return ZEROID;
+	}
+	
 	public static final boolean isId(final String id) {
 		if (id.length() != (2 * Constants.OBJECT_ID_LENGTH)) {
 			return false;
@@ -80,6 +84,8 @@ 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++) {
 			final int ak = a[k] & 0xff;
 			final int bk = b[k] & 0xff;

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

* [EGIT PATCH 05/10] Cache commits
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (3 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 04/10] Speed up history by comparing tree hashes Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 06/10] Allow history listing on folders and projects Robin Rosenberg
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

This uses more memory, but by having a WeakMap we allow the
garbage collector to claim the memory if needed. This speeds
up the history panel enormously, so that having the history
pane connected to the selected resource is not a performance
problem (except the first time the history of a resource in
a projects is shown).

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

 .../src/org/spearce/jgit/lib/Repository.java       |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

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 781ad90..f7c470d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -25,6 +25,8 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Map;
+import java.util.WeakHashMap;
 
 import org.spearce.jgit.errors.IncorrectObjectTypeException;
 import org.spearce.jgit.errors.ObjectWritingException;
@@ -45,6 +47,8 @@ public class Repository {
 
 	private WindowCache windows;
 
+	private Map cache = new WeakHashMap(30000); 
+
 	public Repository(final File d) throws IOException {
 		gitDir = d.getAbsoluteFile();
 		objectsDir = new File(gitDir, "objects");
@@ -185,12 +189,19 @@ public class Repository {
 	}
 
 	public Commit mapCommit(final ObjectId id) throws IOException {
+		Commit ret = (Commit)cache.get(id);
+		if (ret != null)
+			return ret;
+
 		final ObjectLoader or = openObject(id);
 		if (or == null)
 			return null;
 		final byte[] raw = or.getBytes();
-		if (Constants.TYPE_COMMIT.equals(or.getType()))
-			return new Commit(this, id, raw);
+		if (Constants.TYPE_COMMIT.equals(or.getType())) {
+			ret = new Commit(this, id, raw);
+			cache.put(id, ret);
+			return ret;
+		}
 		throw new IncorrectObjectTypeException(id, Constants.TYPE_COMMIT);
 	}
 

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

* [EGIT PATCH 06/10] Allow history listing on folders and projects.
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (4 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 05/10] Cache commits Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 07/10] Return nothing if no version exists for a commit Robin Rosenberg
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

Comparing two commits is disabled on a none-file resource until
we implement the structured compare interfaces.

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

 org.spearce.egit.core/META-INF/MANIFEST.MF         |    3 ++-
 .../egit/core/internal/mapping/GitFileHistory.java |    2 +-
 org.spearce.egit.ui/plugin.xml                     |   21 ++++++++++++--------
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    3 +++
 .../org/spearce/egit/ui/GitHistoryPageSource.java  |    5 ++++-
 5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/org.spearce.egit.core/META-INF/MANIFEST.MF b/org.spearce.egit.core/META-INF/MANIFEST.MF
index a8349a1..13ec59d 100644
--- a/org.spearce.egit.core/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.core/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Export-Package: org.spearce.egit.core.op,
+Export-Package: org.spearce.egit.core.internal.mapping;x-friends:="org.spearce.egit.ui",
+ org.spearce.egit.core.op,
  org.spearce.egit.core.project
 Eclipse-LazyStart: true
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 6c40bb0..2e4e4e9 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
@@ -158,7 +158,7 @@ public class GitFileHistory extends FileHistory {
 				}
 			}
 			
-			if (!currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
+			if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
 				ret.add(new GitFileRevision(previous, resource));
 
 			lastResourceHash = currentResourceHash;
diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml
index d373d18..d81a0b6 100644
--- a/org.spearce.egit.ui/plugin.xml
+++ b/org.spearce.egit.ui/plugin.xml
@@ -50,7 +50,19 @@
                tooltip="%TrackAction_tooltip"
                menubarPath="team.main/group1"
                id="org.spearce.egit.ui.internal.actions.Track"/>
- 	 </objectContribution>
+         <action
+               class="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction"
+               id="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction"
+               label="%ShowResourceInHistoryAction_label"
+               menubarPath="team.main/group1"
+               tooltip="%ShowResourceInHistoryAction_tooltip"/>
+		<action
+		       class="org.spearce.egit.ui.internal.actions.GitCompareRevisionAction"
+        	   id="org.spearce.egit.ui.internal.actions.GitCompareAction"
+               menubarPath="team.main/group1"
+        	   label="Structured Git Compare">
+		</action>
+ 	  </objectContribution>
       <objectContribution
             objectClass="org.eclipse.core.resources.IFile"
             adaptable="true"
@@ -68,13 +80,6 @@
                overrideActionId="org.eclipse.team.ui.compareLocalHistory"
                tooltip="%CompareWithRevisionAction_tooltip">
          </action>
-         <action
-               class="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction"
-               enablesFor="1"
-               id="org.spearce.egit.ui.internal.actions.ShowResourceInHistoryAction"
-               label="%ShowResourceInHistoryAction_label"
-               menubarPath="team.main/group1"
-               tooltip="%ShowResourceInHistoryAction_tooltip"/>
       </objectContribution>
    </extension>
 
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 0e53036..cd31f18 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
@@ -62,6 +62,7 @@ import org.eclipse.team.internal.ui.history.DialogHistoryPageSite;
 import org.eclipse.team.ui.history.HistoryPage;
 import org.eclipse.team.ui.history.IHistoryCompareAdapter;
 import org.eclipse.team.ui.history.IHistoryPageSite;
+import org.spearce.egit.core.internal.mapping.GitFileRevision;
 
 public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		IHistoryCompareAdapter {
@@ -115,6 +116,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				compareAction.setCurrentFileRevision(fileRevisions[0]);
 				compareAction.selectionChanged(new StructuredSelection(
 						selection2));
+				
+				compareAction.setEnabled(selection!=null && selection[0]!=null  && ((GitFileRevision)fileRevisions[0]).getResource().getType() == IResource.FILE);
 			}
 		});
 		compareAction.setPage(this);
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java
index 03c1896..2d56063 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPageSource.java
@@ -27,7 +27,10 @@ public class GitHistoryPageSource extends HistoryPageSource {
 	}
 
 	public boolean canShowHistoryFor(Object object) {
-		return (object instanceof IResource && ((IResource) object).getType() == IResource.FILE);
+		return (object instanceof IResource 
+				&& (((IResource) object).getType() == IResource.FILE
+						|| ((IResource) object).getType() == IResource.FOLDER
+						|| ((IResource) object).getType() == IResource.PROJECT));
 	}
 
 }

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

* [EGIT PATCH 07/10] Return nothing if no version exists for a commit.
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (5 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 06/10] Allow history listing on folders and projects Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:15 ` [EGIT PATCH 08/10] Show only commits that represent changes in the history view Robin Rosenberg
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

I used a null reference to mean two things, which meant the
working directory version was retrieved for comparing files
when a commit did not include a named blob.

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

 .../src/org/spearce/egit/core/GitStorage.java      |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java b/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
index e53fd83..ce4ff71 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
@@ -41,7 +41,10 @@ public class GitStorage implements IStorage {
 
 	private TreeEntry entry;
 
+	private ObjectId treeId;
+
 	public GitStorage(ObjectId treeId, IResource resource) {
+		this.treeId = treeId;
 		this.resource = resource;
 		if (treeId == null)
 			return;
@@ -68,13 +71,17 @@ public class GitStorage implements IStorage {
 
 	public InputStream getContents() throws CoreException {
 		try {
-			if (entry == null) {
+			if (treeId == null) {
 				return ((IFile) resource).getContents();
 			} else {
-				ObjectId id = entry.getId();
-				ObjectLoader reader = entry.getRepository().openBlob(id);
-				byte[] bytes = reader.getBytes();
-				return new ByteArrayInputStream(bytes);
+				if (entry == null)
+					return new ByteArrayInputStream(new byte[0]);
+				else {
+					ObjectId id = entry.getId();
+					ObjectLoader reader = entry.getRepository().openBlob(id);
+					byte[] bytes = reader.getBytes();
+					return new ByteArrayInputStream(bytes);
+				}
 			}
 		} catch (FileNotFoundException e) {
 			throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL,

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

* [EGIT PATCH 08/10] Show only commits that represent changes in the history view
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (6 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 07/10] Return nothing if no version exists for a commit Robin Rosenberg
@ 2007-03-11 18:15 ` Robin Rosenberg
  2007-03-11 18:16 ` [EGIT PATCH 09/10] Hash ObjectId faster Robin Rosenberg
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:15 UTC (permalink / raw)
  To: spearce; +Cc: git

The reason other commits were there originally was that it was useful
for debugging to see the last and first commit. I think that is no 
longer the case.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../egit/core/GitWorkspaceFileRevision.java        |    2 -
 .../egit/core/internal/mapping/GitFileHistory.java |   70 +++++++++++++++++++++--
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    7 ++
 3 files changed, 69 insertions(+), 10 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java b/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
index 5c3b820..82047c7 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
@@ -62,6 +62,6 @@ public class GitWorkspaceFileRevision extends GitFileRevision implements
 	}
 
 	public String getContentIdentifier() {
-		return null;
+		return "Workspace";
 	}
 }
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 2e4e4e9..6c114e9 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
@@ -16,7 +16,9 @@
  */
 package org.spearce.egit.core.internal.mapping;
 
+import java.io.BufferedInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -25,12 +27,14 @@ import java.util.Date;
 import java.util.List;
 
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.team.core.RepositoryProvider;
 import org.eclipse.team.core.history.IFileHistoryProvider;
 import org.eclipse.team.core.history.IFileRevision;
 import org.eclipse.team.core.history.provider.FileHistory;
 import org.spearce.egit.core.GitProvider;
 import org.spearce.egit.core.GitWorkspaceFileRevision;
+import org.spearce.egit.core.project.GitProjectData;
 import org.spearce.egit.core.project.RepositoryMapping;
 import org.spearce.jgit.lib.Commit;
 import org.spearce.jgit.lib.ObjectId;
@@ -95,10 +99,14 @@ public class GitFileHistory extends FileHistory {
 		return getRepositoryMapping().getRepository();
 	}
 
-	private RepositoryMapping getRepositoryMapping() {
+	private GitProjectData getData() {
 		GitProvider provider = (GitProvider) RepositoryProvider
 				.getProvider(resource.getProject());
-		return provider.getData().getRepositoryMapping(resource.getProject());
+		return provider.getData();
+	}
+
+	private RepositoryMapping getRepositoryMapping() {
+		return getData().getRepositoryMapping(resource.getProject());
 	}
 
 	private Collection collectHistory() {
@@ -108,6 +116,15 @@ public class GitFileHistory extends FileHistory {
 			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(initialResourceHash, null,
 					repository, commit);
 		} catch (IOException e) {
@@ -195,7 +212,6 @@ public class GitFileHistory extends FileHistory {
 				current = null;
 
 		} while (current != null);
-		ret.add(new GitFileRevision(previous, resource));
 
 		return ret;
 	}
@@ -251,13 +267,39 @@ public class GitFileHistory extends FileHistory {
 		RepositoryProvider provider = RepositoryProvider.getProvider(resource
 				.getProject());
 		if (provider instanceof GitProvider) {
-
-			List ret = new ArrayList();
-			ret.add(new GitWorkspaceFileRevision(resource));
+			GitWorkspaceFileRevision wsrevision = new GitWorkspaceFileRevision(resource);
 
 			long time0 = new Date().getTime();
 			System.out.println("getting file history");
-			ret.addAll(collectHistory());
+			List ret = new ArrayList();
+			Collection githistory = collectHistory();
+			if (githistory.size() >0) {
+				if (resource.getType()==IResource.FILE) {
+					// TODO: consider index in future versions
+					try {
+						InputStream wsContents = new BufferedInputStream(wsrevision.getStorage(null).getContents());
+						InputStream headContents = ((IFileRevision)githistory.toArray()[0]).getStorage(null).getContents();
+						if (!streamsEqual(wsContents,headContents)) {
+							ret.add(wsrevision);
+							ret.addAll(githistory);
+						} else {
+							ret.addAll(githistory);
+						}
+						wsContents.close();
+						headContents.close();
+					} catch (IOException e) {
+						// TODO: Eclipse error handling
+						e.printStackTrace();
+					} catch (CoreException e) {
+						// TODO: Eclipse error handling
+						e.printStackTrace();
+					}
+				} else {
+					ret.addAll(githistory);
+				}
+			} else {
+				ret.add(wsrevision);
+			}
 			long time1 = new Date().getTime();
 			System.out.println("got file history in " + (time1 - time0)
 					/ 1000.0 + "s");
@@ -270,6 +312,20 @@ public class GitFileHistory extends FileHistory {
 		}
 	}
 
+	private boolean streamsEqual(InputStream s1, InputStream s2) {
+		// Speed up...
+		try {
+			int c1,c2;
+			while ((c1=s1.read()) == (c2=s2.read()) && c1!=-1)
+				;
+			return c1 == -1 && c2==-1;
+		} catch (IOException e) {
+			// TODO: eclipse error handling
+			e.printStackTrace();
+			return false;
+		}
+	}
+
 	public IFileRevision[] getTargets(IFileRevision revision) {
 		GitFileRevision grevision = (GitFileRevision) revision;
 		ObjectId targetCommitId = grevision.getCommit().getCommitId();
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 cd31f18..77073f2 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
@@ -156,7 +156,10 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 			if (columnIndex == 0) {
 				String id = ((IFileRevision) element).getContentIdentifier();
 				if (id != null)
-					return id.substring(0, 7) + "..";
+					if (id.length() > 9) // make sure "Workspace" is spelled out
+						return id.substring(0, 7) + "..";
+					else
+						return id;
 				else
 					return id;
 			}
@@ -211,7 +214,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 						if (text != null)
 							item.setText(i, text);
 						else
-							item.setText("");
+							item.setText(i, "");
 					}
 					item.setData(fileRevisions[event.index]);
 				}

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

* [EGIT PATCH 09/10] Hash ObjectId faster.
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (7 preceding siblings ...)
  2007-03-11 18:15 ` [EGIT PATCH 08/10] Show only commits that represent changes in the history view Robin Rosenberg
@ 2007-03-11 18:16 ` Robin Rosenberg
  2007-03-11 18:16 ` [EGIT PATCH 10/10] Display distance to head in history page Robin Rosenberg
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:16 UTC (permalink / raw)
  To: spearce; +Cc: git

ObjectId's are well distributed so we can grab the first four bytes
as the hash code. The assumption makes hashing faster.

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

 .../src/org/spearce/jgit/lib/ObjectId.java         |   13 +++++++------
 1 files changed, 7 insertions(+), 6 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 9e62424..45e23e6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -163,12 +163,13 @@ public class ObjectId implements Comparable {
 	}
 
 	public int hashCode() {
-		int r = 0;
-		for (int k = id.length - 1; k >= 0; k--) {
-			r *= 31;
-			r += id[k];
-		}
-		return r;
+		// Object Id' are well distributed so grab the first four bytes
+		int b0 = id[0] & 0xff;
+		int b1 = id[1] & 0xff;
+		int b2 = id[2] & 0xff;
+		int b3 = id[3] & 0xff;
+		int h = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
+		return h;
 	}
 
 	public boolean equals(final ObjectId o) {

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

* [EGIT PATCH 10/10] Display distance to head in history page
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (8 preceding siblings ...)
  2007-03-11 18:16 ` [EGIT PATCH 09/10] Hash ObjectId faster Robin Rosenberg
@ 2007-03-11 18:16 ` Robin Rosenberg
  2007-03-11 20:11 ` [PATCH 0/2] Series short description Robin Rosenberg
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 18:16 UTC (permalink / raw)
  To: spearce; +Cc: git

This makes it more apparent that the list is filtered and
when changes occurred.

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

 .../egit/core/GitWorkspaceFileRevision.java        |    2 -
 .../egit/core/internal/mapping/GitFileHistory.java |   19 +++---
 .../core/internal/mapping/GitFileRevision.java     |    9 ++-
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |   74 +++++++++++++++--------
 4 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java b/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
index 82047c7..9aa3593 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java
@@ -28,7 +28,7 @@ public class GitWorkspaceFileRevision extends GitFileRevision implements
 	private final IResource resource;
 
 	public GitWorkspaceFileRevision(IResource resource) {
-		super(null, resource);
+		super(null, resource, -1);
 		this.resource = resource;
 	}
 
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 6c114e9..78a2e68 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
@@ -72,7 +72,7 @@ public class GitFileHistory extends FileHistory {
 			try {
 				ret[i] = new GitFileRevision(repository
 						.mapCommit((ObjectId) parents.get(i)), grevision
-						.getResource());
+				.getResource(), -1);
 			} catch (IOException e) {
 				e.printStackTrace();
 				return null;
@@ -87,7 +87,7 @@ public class GitFileHistory extends FileHistory {
 		} else {
 			try {
 				Repository repository = getRepository();
-				return new GitFileRevision(repository.mapCommit(id), resource);
+				return new GitFileRevision(repository.mapCommit(id), resource, 0);
 			} catch (IOException e) {
 				e.printStackTrace();
 				return null;
@@ -125,7 +125,7 @@ public class GitFileHistory extends FileHistory {
 			}
 			if (activeDiffTreeEntries!=null)
 				initialResourceHash[initialResourceHash.length-1] = activeDiffTreeEntries[0].getId();
-			return collectHistory(initialResourceHash, null,
+			return collectHistory(0, initialResourceHash, null,
 					repository, commit);
 		} catch (IOException e) {
 			e.printStackTrace();
@@ -133,7 +133,7 @@ public class GitFileHistory extends FileHistory {
 		}
 	}
 
-	private Collection collectHistory(ObjectId[] lastResourceHash, TreeEntry lastEntry,
+	private Collection collectHistory(int count, ObjectId[] lastResourceHash, TreeEntry lastEntry,
 			Repository repository, Commit top) throws IOException {
 		if (top == null)
 			return Collections.EMPTY_LIST;
@@ -176,7 +176,7 @@ public class GitFileHistory extends FileHistory {
 			}
 			
 			if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
-				ret.add(new GitFileRevision(previous, resource));
+				ret.add(new GitFileRevision(previous, resource, count));
 
 			lastResourceHash = currentResourceHash;
 			previous = current;
@@ -190,7 +190,7 @@ public class GitFileHistory extends FileHistory {
 					Commit mergeParent;
 					try {
 						mergeParent = repository.mapCommit(mergeParentId);
-						ret.addAll(collectHistory(lastResourceHash, currentEntry, repository, 
+						ret.addAll(collectHistory(0, lastResourceHash, currentEntry, repository, 
 								mergeParent));
 						// TODO: this gets us a lot of duplicates that we need
 						// to filter out
@@ -210,7 +210,8 @@ public class GitFileHistory extends FileHistory {
 				}
 			} else
 				current = null;
-
+			if (count>=0)
+				count++;
 		} while (current != null);
 
 		return ret;
@@ -252,8 +253,8 @@ public class GitFileHistory extends FileHistory {
 				((Tree)currentEntry).findMember(relativeResourceName[i]);
 			}
 			if (currentEntry != null)
-				revisions = new IFileRevision[] { new GitFileRevision(current,
-						resource) };
+				revisions = new IFileRevision[] { new GitFileRevision(current, resource,
+						-1) };
 			else
 				revisions = new IFileRevision[0];
 
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileRevision.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileRevision.java
index 31e2191..ad15cc0 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileRevision.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileRevision.java
@@ -44,7 +44,10 @@ public class GitFileRevision extends FileRevision {
 
 	private final Commit commit;
 
-	public GitFileRevision(Commit commit, IResource resource) {
+	private final int count;
+
+	public GitFileRevision(Commit commit, IResource resource, int count) {
+		this.count = count;
 		this.commit = commit;
 		this.resource = resource;
 	}
@@ -129,4 +132,8 @@ public class GitFileRevision extends FileRevision {
 	public IResource getResource() {
 		return resource;
 	}
+
+	public int getCount() {
+		return count;
+	}
 }
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 77073f2..54635f5 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
@@ -154,6 +154,19 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 
 		public String getColumnText(Object element, int columnIndex) {
 			if (columnIndex == 0) {
+				int count = ((GitFileRevision) element).getCount();
+				if (count < 0)
+					return "";
+				else
+					if (count == 0)
+						return "HEAD";
+					else
+						return "HEAD~"+count;
+			}
+			
+			if (columnIndex == 1) {
+				String rss = ((IFileRevision) element).getURI().toString();
+				String rs = rss.substring(rss.length()-10);
 				String id = ((IFileRevision) element).getContentIdentifier();
 				if (id != null)
 					if (id.length() > 9) // make sure "Workspace" is spelled out
@@ -161,20 +174,20 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 					else
 						return id;
 				else
-					return id;
+					return id + "@.." + rs;
 			}
 
-			if (columnIndex == 1)
+			if (columnIndex == 2)
 				return ""; // TAGS
 
-			if (columnIndex == 2)
+			if (columnIndex == 3)
 				return new Date(((IFileRevision) element).getTimestamp())
 						.toString();
 
-			if (columnIndex == 3)
+			if (columnIndex == 4)
 				return ((IFileRevision) element).getAuthor();
 
-			if (columnIndex == 4) {
+			if (columnIndex == 5) {
 				String comment = ((IFileRevision) element).getComment();
 				if (comment == null)
 					return null;
@@ -186,8 +199,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 			}
 			return Integer.toString(columnIndex);
 		}
-
-	}
+	};
 
 	private void createTree(Composite composite) {
 		tree = new Tree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
@@ -200,23 +212,27 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		tree.setData("HEAD");
 		tree.addListener(SWT.SetData, new Listener() {
 			public void handleEvent(Event event) {
-				TreeItem item = (TreeItem) event.item;
-				Tree parent = item.getParent();
-				if (parent == null) {
-					item.setText(new String[] { "hej", "san" });
-					item.setData("");
-				} else {
-					ITableLabelProvider p = (ITableLabelProvider) viewer
-							.getLabelProvider();
-					for (int i = 0; i < 5; ++i) {
-						String text = p.getColumnText(
-								fileRevisions[event.index], i);
-						if (text != null)
-							item.setText(i, text);
-						else
-							item.setText(i, "");
+				try {
+					TreeItem item = (TreeItem) event.item;
+					Tree parent = item.getParent();
+					if (parent == null) {
+						item.setText(new String[] { "hej", "san" });
+						item.setData("");
+					} else {
+						ITableLabelProvider p = (ITableLabelProvider) viewer
+								.getLabelProvider();
+						for (int i = 0; i < 6; ++i) {
+							String text = p.getColumnText(
+									fileRevisions[event.index], i);
+							if (text != null)
+								item.setText(i, text);
+							else
+								item.setText(i, "");
+						}
+						item.setData(fileRevisions[event.index]);
 					}
-					item.setData(fileRevisions[event.index]);
+				} catch (Throwable b) {
+					b.printStackTrace();
 				}
 			}
 		});
@@ -294,12 +310,20 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 
 	private void createColumns() {
 		// X SelectionListener headerListener = getColumnListener(viewer);
-		// revision
+		// count from head
 		TreeColumn col = new TreeColumn(tree, SWT.NONE);
 		col.setResizable(true);
+		col.setText("^");
+		// X col.addSelectionListener(headerListener);
+		((TableLayout) tree.getLayout()).addColumnData(new ColumnWeightData(10,
+				true));
+
+		// revision
+		col = new TreeColumn(tree, SWT.NONE);
+		col.setResizable(true);
 		col.setText(TeamUIMessages.GenericHistoryTableProvider_Revision);
 		// X col.addSelectionListener(headerListener);
-		((TableLayout) tree.getLayout()).addColumnData(new ColumnWeightData(20,
+		((TableLayout) tree.getLayout()).addColumnData(new ColumnWeightData(10,
 				true));
 
 		// tags

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

* [PATCH 0/2] Series short description
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (9 preceding siblings ...)
  2007-03-11 18:16 ` [EGIT PATCH 10/10] Display distance to head in history page Robin Rosenberg
@ 2007-03-11 20:11 ` Robin Rosenberg
  2007-03-11 20:19   ` Shawn O. Pearce
  2007-03-11 20:11 ` [PATCH 1/2] Tag version 0.2.1 Robin Rosenberg
  2007-03-11 20:11 ` [PATCH 2/2] Re-add qualfiier for development version Robin Rosenberg
  12 siblings, 1 reply; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 20:11 UTC (permalink / raw)
  To: spearce, git

The following series implements...

-- 
Signature

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

* [PATCH 1/2] Tag version 0.2.1
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (10 preceding siblings ...)
  2007-03-11 20:11 ` [PATCH 0/2] Series short description Robin Rosenberg
@ 2007-03-11 20:11 ` Robin Rosenberg
  2007-03-11 20:11 ` [PATCH 2/2] Re-add qualfiier for development version Robin Rosenberg
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 20:11 UTC (permalink / raw)
  To: spearce, git

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

 org.spearce.egit.core/META-INF/MANIFEST.MF |    2 +-
 org.spearce.egit.ui/META-INF/MANIFEST.MF   |    2 +-
 org.spearce.jgit/META-INF/MANIFEST.MF      |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/org.spearce.egit.core/META-INF/MANIFEST.MF b/org.spearce.egit.core/META-INF/MANIFEST.MF
index 13ec59d..fd90a0c 100644
--- a/org.spearce.egit.core/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.egit.core; singleton:=true
-Bundle-Version: 0.2.0.qualifier
+Bundle-Version: 0.2.1
 Bundle-Activator: org.spearce.egit.core.Activator
 Bundle-Vendor: %provider_name
 Bundle-Localization: plugin
diff --git a/org.spearce.egit.ui/META-INF/MANIFEST.MF b/org.spearce.egit.ui/META-INF/MANIFEST.MF
index 63dcec8..8075883 100644
--- a/org.spearce.egit.ui/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.egit.ui; singleton:=true
-Bundle-Version: 0.2.0.qualifier
+Bundle-Version: 0.2.1
 Bundle-Activator: org.spearce.egit.ui.Activator
 Bundle-Vendor: %plugin_provider
 Bundle-Localization: plugin
diff --git a/org.spearce.jgit/META-INF/MANIFEST.MF b/org.spearce.jgit/META-INF/MANIFEST.MF
index 1485bb9..9bbddb3 100644
--- a/org.spearce.jgit/META-INF/MANIFEST.MF
+++ b/org.spearce.jgit/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.jgit
-Bundle-Version: 0.2.0.qualifier
+Bundle-Version: 0.2.1
 Bundle-Localization: plugin
 Bundle-Vendor: %provider_name
 Export-Package: org.spearce.jgit.errors,

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

* [PATCH 2/2] Re-add qualfiier for development version
  2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
                   ` (11 preceding siblings ...)
  2007-03-11 20:11 ` [PATCH 1/2] Tag version 0.2.1 Robin Rosenberg
@ 2007-03-11 20:11 ` Robin Rosenberg
  12 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 20:11 UTC (permalink / raw)
  To: spearce, git

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

 org.spearce.egit.core/META-INF/MANIFEST.MF |    2 +-
 org.spearce.egit.ui/META-INF/MANIFEST.MF   |    2 +-
 org.spearce.jgit/META-INF/MANIFEST.MF      |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/org.spearce.egit.core/META-INF/MANIFEST.MF b/org.spearce.egit.core/META-INF/MANIFEST.MF
index fd90a0c..f4c96cc 100644
--- a/org.spearce.egit.core/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.egit.core; singleton:=true
-Bundle-Version: 0.2.1
+Bundle-Version: 0.2.1.qualifier
 Bundle-Activator: org.spearce.egit.core.Activator
 Bundle-Vendor: %provider_name
 Bundle-Localization: plugin
diff --git a/org.spearce.egit.ui/META-INF/MANIFEST.MF b/org.spearce.egit.ui/META-INF/MANIFEST.MF
index 8075883..18b7e87 100644
--- a/org.spearce.egit.ui/META-INF/MANIFEST.MF
+++ b/org.spearce.egit.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.egit.ui; singleton:=true
-Bundle-Version: 0.2.1
+Bundle-Version: 0.2.1.qualifier
 Bundle-Activator: org.spearce.egit.ui.Activator
 Bundle-Vendor: %plugin_provider
 Bundle-Localization: plugin
diff --git a/org.spearce.jgit/META-INF/MANIFEST.MF b/org.spearce.jgit/META-INF/MANIFEST.MF
index 9bbddb3..f671eb9 100644
--- a/org.spearce.jgit/META-INF/MANIFEST.MF
+++ b/org.spearce.jgit/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin_name
 Bundle-SymbolicName: org.spearce.jgit
-Bundle-Version: 0.2.1
+Bundle-Version: 0.2.1.qualifier
 Bundle-Localization: plugin
 Bundle-Vendor: %provider_name
 Export-Package: org.spearce.jgit.errors,

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

* Re: [PATCH 0/2] Series short description
  2007-03-11 20:11 ` [PATCH 0/2] Series short description Robin Rosenberg
@ 2007-03-11 20:19   ` Shawn O. Pearce
  2007-03-11 20:45     ` Robin Rosenberg
  0 siblings, 1 reply; 16+ messages in thread
From: Shawn O. Pearce @ 2007-03-11 20:19 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> The following series implements...

Exciting new features?  ;-)
 
-- 
Shawn.

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

* Re: [PATCH 0/2] Series short description
  2007-03-11 20:19   ` Shawn O. Pearce
@ 2007-03-11 20:45     ` Robin Rosenberg
  0 siblings, 0 replies; 16+ messages in thread
From: Robin Rosenberg @ 2007-03-11 20:45 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

söndag 11 mars 2007 21:19 skrev Shawn O. Pearce:
> Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> > The following series implements...
> 
> Exciting new features?  ;-)

Indeed.  I thought it'd be better if you read the patch rather
than a misleading subject. :)

Actually, I exited vi with :q! and stacked git didn't realize this. :( 

-- robin

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

end of thread, other threads:[~2007-03-11 20:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 01/10] Git history refresh problem Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 02/10] Support commit encoding header Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 03/10] Avoid a nullpointerexception on shutdown Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 04/10] Speed up history by comparing tree hashes Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 05/10] Cache commits Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 06/10] Allow history listing on folders and projects Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 07/10] Return nothing if no version exists for a commit Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 08/10] Show only commits that represent changes in the history view Robin Rosenberg
2007-03-11 18:16 ` [EGIT PATCH 09/10] Hash ObjectId faster Robin Rosenberg
2007-03-11 18:16 ` [EGIT PATCH 10/10] Display distance to head in history page Robin Rosenberg
2007-03-11 20:11 ` [PATCH 0/2] Series short description Robin Rosenberg
2007-03-11 20:19   ` Shawn O. Pearce
2007-03-11 20:45     ` Robin Rosenberg
2007-03-11 20:11 ` [PATCH 1/2] Tag version 0.2.1 Robin Rosenberg
2007-03-11 20:11 ` [PATCH 2/2] Re-add qualfiier for development version Robin Rosenberg

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).