]> source.dussan.org Git - jgit.git/commitdiff
Add isSuccessful to MergeStatus, RebaseResult.Status and PullResult 49/3949/3
authorRobin Stocker <robin@nibor.org>
Tue, 9 Aug 2011 21:31:50 +0000 (23:31 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 9 Aug 2011 21:31:50 +0000 (23:31 +0200)
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>
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PullResult.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java

index 1ec8685f7eca2b7d88ee6b6fe6cf12dc6ab209a8..86e4e78c8c70b6816f2618e14228362d10c690d8 100644 (file)
@@ -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;
index 40ed137ee053db9e872d8e7f0233f5afd4edd469..49327fc9b92cdc18f614232ce69f3e90c699e319 100644 (file)
@@ -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();
index af070d6535e88555af075b22d1960662e0e65dba..07cd8eb20ae97d473208cb146958c8dd42b2c190 100644 (file)
@@ -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);