{"thread":{"id":"11731","subject":"[EGIT PATCH] showing commiter and parent commit(s) on the revision detail viewer","startedAt":"2008-01-25T12:02:09Z","lastAt":"2008-01-27T00:34:10Z","messageCount":2,"participants":["Roger C. Soares","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"66558","messageId":"1201262529-3306-1-git-send-email-rogersoares@intelinet.com.br","threadId":"11731","inReplyTo":null,"subject":"[EGIT PATCH] showing commiter and parent commit(s) on the revision detail viewer","fromName":"Roger C. Soares","fromEmail":"rogersoares@intelinet.com.br","sentAt":"2008-01-25T12:02:09Z","receivedAt":"2008-01-25T12:02:09Z","isPatch":true,"sender":{"key":"rogersoares@intelinet.com.br","avatar":null},"body":"---\n .../src/org/spearce/egit/ui/GitHistoryPage.java    |   57 +++++++++++++++++---\n 1 files changed, 49 insertions(+), 8 deletions(-)\n\ndiff --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\nindex 649df3f..cc11b97 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java\n@@ -88,7 +88,9 @@ import org.spearce.egit.core.internal.mapping.GitFileHistoryProvider;\n import org.spearce.egit.core.internal.mapping.GitFileRevision;\n import org.spearce.egit.core.project.RepositoryMapping;\n import org.spearce.egit.ui.internal.actions.GitCompareRevisionAction;\n+import org.spearce.jgit.lib.Commit;\n import org.spearce.jgit.lib.ObjectId;\n+import org.spearce.jgit.lib.PersonIdent;\n import org.spearce.jgit.lib.Tag;\n import org.spearce.jgit.lib.TopologicalSorter;\n import org.spearce.jgit.lib.Repository.StGitPatch;\n@@ -221,14 +223,16 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\t\tif(selection2.length == 1) {\n \t\t\t\t\t// if the table item is not visible in the UI and it's selected via keyboard\n \t\t\t\t\t// this listener is called before the listener that sets the item data.\n-\t\t\t\t\tif(selection2[0] == null) {\n+\t\t\t\t\tGitCommitFileRevision revision = (GitCommitFileRevision) selection2[0];\n+\t\t\t\t\tif(revision == null) {\n \t\t\t\t\t\tint ix = table.getSelectionIndex();\n-\t\t\t\t\t\tGitFileRevision revision = (GitFileRevision) fileRevisions.get(ix);\n+\t\t\t\t\t\trevision = (GitCommitFileRevision) fileRevisions.get(ix);\n \t\t\t\t\t\tselection2[0] = revision;\n \t\t\t\t\t}\n-\t\t\t\t\tsetRevisionInfoTextViewers(selection2[0]);\n+\t\t\t\t\tsetRevisionInfoTextViewers(revision);\n \t\t\t\t}\n \n+\n \t\t\t\tcompareAction.setCurrentFileRevision(fileRevisions.get(0));\n \t\t\t\tcompareAction.selectionChanged(new StructuredSelection(\n \t\t\t\t\t\tselection2));\n@@ -554,7 +558,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\trevCommentTextViewer = new TextViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);\n \t}\n \n-\t/* private */void setRevisionInfoTextViewers(IFileRevision rev) {\n+\t/* private */void setRevisionInfoTextViewers(GitCommitFileRevision rev) {\n \t\tStringBuilder revisionInfo = new StringBuilder();\n \t\tif (appliedPatches != null) {\n \t\t\tString id = rev.getContentIdentifier();\n@@ -570,7 +574,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\t}\n \t\t}\n \t\tif (revisionInfo.length() == 0) {\n-\t\t\trevisionInfo.append(\"Commit: \");\n+\t\t\trevisionInfo.append(\"Commit ID: \");\n \t\t\trevisionInfo.append(rev.getContentIdentifier());\n \t\t}\n \n@@ -673,10 +677,30 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\te.printStackTrace();\n \t\t}\n \n+\t\tCommit commit = rev.getCommit();\n \t\trevisionInfo.append(\"\\nAuthor: \");\n-\t\trevisionInfo.append(rev.getAuthor());\n-\t\trevisionInfo.append(\"\\nDate: \");\n-\t\trevisionInfo.append(DATETIMETZ_FORMAT.format(new Date(rev.getTimestamp())));\n+\t\trevisionInfo.append(formatPersonIdentForRevInfo(commit.getAuthor()));\n+\t\trevisionInfo.append(\"\\nCommiter: \");\n+\t\trevisionInfo.append(formatPersonIdentForRevInfo(commit.getCommitter()));\n+\t\tif(commit.getParentIds() != null) {\n+\t\t\tfor(ObjectId pid : commit.getParentIds()) {\n+\t\t\t\trevisionInfo.append(\"\\nParent: \");\n+\t\t\t\trevisionInfo.append(pid.toString());\n+\t\t\t\ttry {\n+\t\t\t\t\tCommit pc = repositoryMapping.getRepository().mapCommit(pid);\n+\t\t\t\t\trevisionInfo.append(\" (\");\n+\t\t\t\t\tString cmesg = pc.getMessage();\n+\t\t\t\t\tint enterIndex = cmesg.indexOf(\"\\n\");\n+\t\t\t\t\tif(enterIndex > 0) {\n+\t\t\t\t\t\tcmesg = cmesg.substring(0, enterIndex);\n+\t\t\t\t\t}\n+\t\t\t\t\trevisionInfo.append(cmesg);\n+\t\t\t\t\trevisionInfo.append(\" )\");\n+\t\t\t\t} catch (IOException e) {\n+\t\t\t\t\te.printStackTrace();\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n \n \t\tString comment = rev.getComment();\n \t\trevDetailTextViewer.setDocument(new Document(revisionInfo.toString()));\n@@ -691,6 +715,23 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\tif (workbenchPageSite != null) {\n \t\t\tworkbenchPageSite.getActionBars().getStatusLineManager().setMessage(comment);\n \t\t}\n+\n+\t}\n+\n+\tprivate String formatPersonIdentForRevInfo(PersonIdent p) {\n+\t\tStringBuilder sb = new StringBuilder();\n+\t\tsb.append(p.getName());\n+\t\tif(p.getEmailAddress() != null) {\n+\t\t\tsb.append(\" <\");\n+\t\t\tsb.append(p.getEmailAddress());\n+\t\t\tsb.append(\">\");\n+\t\t}\n+\t\tif(p.getWhen() != null) {\n+\t\t\tsb.append(\" \");\n+\t\t\tsb.append(DATETIMETZ_FORMAT.format(p.getWhen()));\n+\t\t}\n+\n+\t\treturn sb.toString();\n \t}\n \n \t/* private */void cleanRevisionInfoTextViewers() {\n-- \n1.5.3.7\n"},{"id":"66652","messageId":"200801270134.11892.robin.rosenberg.lists@dewire.com","threadId":"11731","inReplyTo":"1201262529-3306-1-git-send-email-rogersoares@intelinet.com.br","subject":"Re: [EGIT PATCH] showing commiter and parent commit(s) on the revision detail viewer","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-01-27T00:34:10Z","receivedAt":"2008-01-27T00:34:10Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Hi Roger,\n\nThe general idea is ok. Some minor coments though.\n\n>Re: [EGIT PATCH] showing commiter and parent commit(s) on the revision detail viewer\n\"Show\" and final period.\n\nfredagen den 25 januari 2008 skrev Roger C. Soares:\n> @@ -221,14 +223,16 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n>  \t\t\t\tif(selection2.length == 1) {\n>  \t\t\t\t\t// if the table item is not visible in the UI and it's selected via keyboard\n>  \t\t\t\t\t// this listener is called before the listener that sets the item data.\n> -\t\t\t\t\tif(selection2[0] == null) {\n> +\t\t\t\t\tGitCommitFileRevision revision = (GitCommitFileRevision) selection2[0];\n> +\t\t\t\t\tif(revision == null) {\n>  \t\t\t\t\t\tint ix = table.getSelectionIndex();\n> -\t\t\t\t\t\tGitFileRevision revision = (GitFileRevision) fileRevisions.get(ix);\n> +\t\t\t\t\t\trevision = (GitCommitFileRevision) fileRevisions.get(ix);\n>  \t\t\t\t\t\tselection2[0] = revision;\n>  \t\t\t\t\t}\n> -\t\t\t\t\tsetRevisionInfoTextViewers(selection2[0]);\n> +\t\t\t\t\tsetRevisionInfoTextViewers(revision);\nI'm rather allergic to casts, so if we could have only one I'd feel better. Something like\n\n\t\t\t\t\tIFileRevision revision = selection2[0];\n\t\t\t\t\tif(revision == null) {\n \t\t\t\t\t\tint ix = table.getSelectionIndex();\n\t\t\t\t\t\trevision = fileRevisions.get(ix);\n \t\t\t\t\t\tselection2[0] = revision;\n \t\t\t\t\t}\n\t\t\t\t\tsetRevisionInfoTextViewers((GitCommitFileRevision)revision);\n\n>  \t\t\t\t}\n>  \n> +\ntwo lines of whitepspace\n\n>  \t\tif (revisionInfo.length() == 0) {\n> -\t\t\trevisionInfo.append(\"Commit: \");\n> +\t\t\trevisionInfo.append(\"Commit ID: \");\nI prefer just commit. It's shorter and that it is the id is obvious.\n\n> +\t\trevisionInfo.append(formatPersonIdentForRevInfo(commit.getAuthor()));\n> +\t\trevisionInfo.append(\"\\nCommiter: \");\nTwo t's in \"Committer\"\n\n> +\t\t\t\t} catch (IOException e) {\n> +\t\t\t\t\te.printStackTrace();\nWe should start doing error handling better. But that's a separate chapter. Add a // TODO for now. \nI'll address them one all one one go later, unless someone does it for me.\n\n-- robin\n"}]}