aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2011-08-09 17:31:50 (EDT)
committerMatthias Sohn2011-08-09 17:31:50 (EDT)
commit8db5b6a013d9cb076b2cb7122f111bbac317f3f2 (patch)
tree5b9d67e6598f645b075fc29b396ae356cd9574b5
parent86ecf141b6e94f18702224e60e8992cafe4d02bc (diff)
downloadjgit-8db5b6a013d9cb076b2cb7122f111bbac317f3f2.zip
jgit-8db5b6a013d9cb076b2cb7122f111bbac317f3f2.tar.gz
jgit-8db5b6a013d9cb076b2cb7122f111bbac317f3f2.tar.bz2
Add isSuccessful to MergeStatus, RebaseResult.Status and PullResultrefs/changes/49/3949/3
This is useful when the result needs to be displayed and it's only of interest if the operation was successful or not (in egit, it could be used in MultiPullResultDialog). Change-Id: Icfc9a9c76763f8a777087a1262c8d6ad251a9068 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java37
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java47
3 files changed, 88 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
index 1ec8685..86e4e78 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
@@ -70,37 +70,72 @@ public class MergeResult {
public String toString() {
return "Fast-forward";
}
+
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
},
/** */
ALREADY_UP_TO_DATE {
public String toString() {
return "Already-up-to-date";
}
+
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
},
/** */
FAILED {
public String toString() {
return "Failed";
}
+
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
},
/** */
MERGED {
public String toString() {
return "Merged";
}
+
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
},
/** */
CONFLICTING {
public String toString() {
return "Conflicting";
}
+
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
},
/** */
NOT_SUPPORTED {
public String toString() {
return "Not-yet-supported";
}
- }
+
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
+ };
+
+ /**
+ * @return whether the status indicates a successful result
+ */
+ public abstract boolean isSuccessful();
}
private ObjectId[] mergedCommits;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java
index 40ed137..49327fc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java
@@ -101,6 +101,17 @@ public class PullResult {
return this.fetchedFrom;
}
+ /**
+ * @return whether the pull was successful
+ */
+ public boolean isSuccessful() {
+ if (mergeResult != null)
+ return mergeResult.getMergeStatus().isSuccessful();
+ else if (rebaseResult != null)
+ return rebaseResult.getStatus().isSuccessful();
+ return true;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
index af070d6..07cd8eb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
@@ -59,27 +59,62 @@ public class RebaseResult {
/**
* Rebase was successful, HEAD points to the new commit
*/
- OK,
+ OK {
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
+ },
/**
* Aborted; the original HEAD was restored
*/
- ABORTED,
+ ABORTED {
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
+ },
/**
* Stopped due to a conflict; must either abort or resolve or skip
*/
- STOPPED,
+ STOPPED {
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
+ },
/**
* Failed; the original HEAD was restored
*/
- FAILED,
+ FAILED {
+ @Override
+ public boolean isSuccessful() {
+ return false;
+ }
+ },
/**
* Already up-to-date
*/
- UP_TO_DATE,
+ UP_TO_DATE {
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
+ },
/**
* Fast-forward, HEAD points to the new commit
*/
- FAST_FORWARD;
+ FAST_FORWARD {
+ @Override
+ public boolean isSuccessful() {
+ return true;
+ }
+ };
+
+ /**
+ * @return whether the status indicates a successful result
+ */
+ public abstract boolean isSuccessful();
}
static final RebaseResult OK_RESULT = new RebaseResult(Status.OK);