From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: spearce@spearce.org
Cc: git@vger.kernel.org, Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [PATCH] Show tags in history view
Date: Mon, 14 May 2007 01:39:17 +0200 [thread overview]
Message-ID: <11790995573126-git-send-email-robin.rosenberg@dewire.com> (raw)
In-Reply-To: <11790995571637-git-send-email-robin.rosenberg@dewire.com>
Put some content into the Tags field in the history browser. Besides
tags we put matching branch names there too.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/GitHistoryPage.java | 85 ++++++++++++++++++-
.../src/org/spearce/jgit/lib/Repository.java | 2 +-
2 files changed, 81 insertions(+), 6 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 e5d92fe..8850405 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.HashMap;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
@@ -78,6 +79,7 @@ import org.spearce.egit.core.project.RepositoryMapping;
import org.spearce.egit.ui.internal.actions.GitCompareRevisionAction;
import org.spearce.jgit.lib.Commit;
import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.Tag;
import org.spearce.jgit.lib.Repository.StGitPatch;
public class GitHistoryPage extends HistoryPage implements IAdaptable,
@@ -145,7 +147,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
if (item != null && item!=lastItem) {
IFileRevision rev = (IFileRevision) item.getData();
String commitStr=null;
- if (appliedPatches!=null) {
+ if (rev!=null && appliedPatches!=null) {
String id = rev.getContentIdentifier();
if (!id.equals("Workspace")) {
StGitPatch patch = (StGitPatch) appliedPatches.get(new ObjectId(id));
@@ -275,8 +277,34 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
return id + "@.." + rs;
}
- if (columnIndex == 2)
- return ""; // TAGS
+ if (columnIndex == 2) {
+ String id = ((IFileRevision)element).getContentIdentifier();
+ ObjectId oid = new ObjectId(id);
+ StringBuilder b=new StringBuilder();
+ if (tags != null) {
+ Tag[] matching = tags.get(oid);
+ if (matching != null) {
+ for (Tag t : matching) {
+ if (b.length() > 0)
+ b.append(' ');
+ b.append(t.getTag());
+ }
+ }
+ }
+ if (branches != null) {
+ if (b.length() >0)
+ b.append('\n');
+ String[] matching = branches.get(oid);
+ if (matching != null) {
+ for (String t : matching) {
+ if (b.length() > 0)
+ b.append(' ');
+ b.append(t);
+ }
+ }
+ }
+ return b.toString();
+ }
if (columnIndex == 3) {
Date d = new Date(((IFileRevision) element).getTimestamp());
@@ -352,6 +380,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
}
private Map appliedPatches;
+ private Map<ObjectId,Tag[]> tags;
+ private Map<ObjectId, String[]> branches;
class HistoryRefreshJob extends Job {
@@ -373,6 +403,48 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
// TODO Auto-generated catch block
e.printStackTrace();
}
+ Map<ObjectId,Tag[]> newtags = new HashMap<ObjectId,Tag[]>();
+ try {
+ for (String name : repositoryMapping.getRepository().getTags()) {
+ Tag t = repositoryMapping.getRepository().mapTag(name);
+ Tag[] samecommit = newtags.get(t.getObjId());
+ if (samecommit==null) {
+ samecommit = new Tag[] { t };
+ } else {
+ Tag[] n=new Tag[samecommit.length+1];
+ for (int j=0; j<samecommit.length; ++j)
+ n[j] = samecommit[j];
+ n[n.length-1] = t;
+ samecommit = n;
+ }
+ newtags.put(t.getObjId(), samecommit);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Map<ObjectId, String[]> newBranches = new HashMap<ObjectId, String[]>();
+ try {
+ for (String branch : repositoryMapping.getRepository().getBranches()) {
+ ObjectId id = repositoryMapping.getRepository().resolve("refs/heads/"+branch);
+ String[] samecommit = newBranches.get(id);
+ if (samecommit == null) {
+ samecommit = new String[] { branch };
+ } else {
+ String[] n=new String[samecommit.length + 1];
+ for (int j=0; j<samecommit.length; ++j)
+ n[j] = samecommit[j];
+ n[n.length-1] = branch;
+ samecommit = n;
+ }
+ newBranches.put(id, samecommit);
+ }
+ branches = newBranches;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
IFileHistoryProvider fileHistoryProvider = provider
.getFileHistoryProvider();
IFileHistory fileHistoryFor = fileHistoryProvider
@@ -380,7 +452,9 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, monitor);
fileRevisions = fileHistoryFor.getFileRevisions();
- final Map fnewappliedPatches = newappliedPatches;
+ final Map fnewappliedPatches = newappliedPatches;
+ final Map<ObjectId,Tag[]> ftags = newtags;
+
tree.getDisplay().asyncExec(new Runnable() {
public void run() {
@@ -389,8 +463,9 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
tree.setData(fileRevisions);
tree.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
System.out.println("inputchanged, invoking refresh");
- viewer.refresh();
appliedPatches = fnewappliedPatches;
+ tags = ftags;
+ viewer.refresh();
done(Status.OK_STATUS);
}
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 3b2a82c..12beb88 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -470,7 +470,7 @@ public class Repository {
return ref;
}
- public Collection getBranches() {
+ public Collection<String> getBranches() {
return listFilesRecursively(new File(refsDir, "heads"), null);
}
--
1.5.1.1
next prev parent reply other threads:[~2007-05-13 23:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-13 23:39 This week in EGIT - more tags Robin Rosenberg
2007-05-13 23:39 ` [PATCH] Implement simple tags Robin Rosenberg
2007-05-13 23:39 ` [PATCH] Write refs when creating tags Robin Rosenberg
2007-05-13 23:39 ` [PATCH] Implement packed refs Robin Rosenberg
2007-05-13 23:39 ` Robin Rosenberg [this message]
2007-05-14 22:45 ` Shawn O. Pearce
2007-05-14 22:49 ` Robin Rosenberg
2007-05-13 23:48 ` The first patch in the series Robin Rosenberg
2007-05-13 23:48 ` [PATCH] Require JDK1.5 Robin Rosenberg
2007-05-14 1:07 ` Grzegorz Kulewski
2007-05-14 7:21 ` Noel Grandin
2007-05-14 17:24 ` Robin Rosenberg
2007-05-14 20:56 ` [PATCH] Set required execution enviroment Robin Rosenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11790995573126-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).