aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2009-09-29 16:03:40 +0200
committerShawn O. Pearce <spearce@spearce.org>2009-10-01 16:41:43 -0700
commit96690904f53241e825a29be9558be319a0bbfba1 (patch)
treee57d7e7e947233960eedc5f319cae9ca55516ba0
parent4cfc7baf9ee56a282232a243c1bcc5931aa9ea75 (diff)
downloadjgit-96690904f53241e825a29be9558be319a0bbfba1.tar.gz
jgit-96690904f53241e825a29be9558be319a0bbfba1.zip
Include description for missing bundle prereqs
When throwing MissingBundlePrerequisiteException we also include the short description, if available, of each missing object. This is the fix for the following issue: http://code.google.com/p/egit/issues/detail?id=25 Change-Id: I5d45aec7873af76a12170d9a500626a7264f2c42 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java21
2 files changed, 26 insertions, 15 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
index 92d63d2993..2d399543a0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2009, Sasa Zivkov <sasa.zivkov@sap.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -43,7 +44,7 @@
package org.eclipse.jgit.errors;
-import java.util.Collection;
+import java.util.Map;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.transport.URIish;
@@ -54,12 +55,14 @@ import org.eclipse.jgit.transport.URIish;
public class MissingBundlePrerequisiteException extends TransportException {
private static final long serialVersionUID = 1L;
- private static String format(final Collection<ObjectId> ids) {
+ private static String format(final Map<ObjectId, String> missingCommits) {
final StringBuilder r = new StringBuilder();
r.append("missing prerequisite commits:");
- for (final ObjectId p : ids) {
+ for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
r.append("\n ");
- r.append(p.name());
+ r.append(e.getKey().name());
+ if (e.getValue() != null)
+ r.append(" ").append(e.getValue());
}
return r.toString();
}
@@ -69,11 +72,12 @@ public class MissingBundlePrerequisiteException extends TransportException {
*
* @param uri
* URI used for transport
- * @param ids
- * the ids of the base/common object(s) we don't have.
+ * @param missingCommits
+ * the Map of the base/common object(s) we don't have. Keys are
+ * ids of the missing objects and values are short descriptions.
*/
public MissingBundlePrerequisiteException(final URIish uri,
- final Collection<ObjectId> ids) {
- super(uri, format(ids));
+ final Map<ObjectId, String> missingCommits) {
+ super(uri, format(missingCommits));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
index a0d172e0fa..a8f0468cdd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
@@ -3,6 +3,7 @@
* Copyright (C) 2008-2009, Google Inc.
* Copyright (C) 2009, Matthias Sohn <matthias.sohn@sap.com>
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2009, Sasa Zivkov <sasa.zivkov@sap.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
@@ -53,9 +54,10 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.jgit.errors.MissingBundlePrerequisiteException;
@@ -84,7 +86,7 @@ class BundleFetchConnection extends BaseFetchConnection {
InputStream bin;
- final Set<ObjectId> prereqs = new HashSet<ObjectId>();
+ final Map<ObjectId, String> prereqs = new HashMap<ObjectId, String>();
private String lockMessage;
@@ -129,7 +131,11 @@ class BundleFetchConnection extends BaseFetchConnection {
break;
if (line.charAt(0) == '-') {
- prereqs.add(ObjectId.fromString(line.substring(1, 41)));
+ ObjectId id = ObjectId.fromString(line.substring(1, 41));
+ String shortDesc = null;
+ if (line.length() > 42)
+ shortDesc = line.substring(42);
+ prereqs.put(id, shortDesc);
continue;
}
@@ -208,9 +214,10 @@ class BundleFetchConnection extends BaseFetchConnection {
final RevFlag PREREQ = rw.newFlag("PREREQ");
final RevFlag SEEN = rw.newFlag("SEEN");
- final List<ObjectId> missing = new ArrayList<ObjectId>();
+ final Map<ObjectId, String> missing = new HashMap<ObjectId, String>();
final List<RevObject> commits = new ArrayList<RevObject>();
- for (final ObjectId p : prereqs) {
+ for (final Map.Entry<ObjectId, String> e : prereqs.entrySet()) {
+ ObjectId p = e.getKey();
try {
final RevCommit c = rw.parseCommit(p);
if (!c.has(PREREQ)) {
@@ -218,7 +225,7 @@ class BundleFetchConnection extends BaseFetchConnection {
commits.add(c);
}
} catch (MissingObjectException notFound) {
- missing.add(p);
+ missing.put(p, e.getValue());
} catch (IOException err) {
throw new TransportException(transport.uri, "Cannot read commit "
+ p.name(), err);
@@ -252,7 +259,7 @@ class BundleFetchConnection extends BaseFetchConnection {
if (remaining > 0) {
for (final RevObject o : commits) {
if (!o.has(SEEN))
- missing.add(o);
+ missing.put(o, prereqs.get(o));
}
throw new MissingBundlePrerequisiteException(transport.uri, missing);
}