summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarkus Duft2012-06-04 09:37:53 (EDT)
committer Chris Aniszczyk2012-08-08 00:40:21 (EDT)
commit1e75941410e3a6e5a21f3155521e80f6f0a08a47 (patch)
treecda5ddd5ed3eeb024824bec022ac9052a0259bf8
parente9c811d0d08a9c2c748311a13a86b481941a55ce (diff)
downloadjgit-1e75941410e3a6e5a21f3155521e80f6f0a08a47.zip
jgit-1e75941410e3a6e5a21f3155521e80f6f0a08a47.tar.gz
jgit-1e75941410e3a6e5a21f3155521e80f6f0a08a47.tar.bz2
Make CheckoutCommand pass modified files through resultrefs/changes/37/5337/9
This change makes CheckoutCommand pass the list of modified files through the OK result, enabling outside world to react in a smaller scope (for example refresh only resources containing the modified files). Change-Id: I53c50ee09bc0d3ff501bdc25196e52e739c3f1f9 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java15
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java58
2 files changed, 61 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
index 479fbd0..d8efbe7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
@@ -46,6 +46,7 @@ package org.eclipse.jgit.api;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -135,7 +136,7 @@ public class CheckoutCommand extends GitCommand<Ref> {
try {
if (checkoutAllPaths || !paths.isEmpty()) {
checkoutPaths();
- status = CheckoutResult.OK_RESULT;
+ status = new CheckoutResult(Status.OK, paths);
setCallable(false);
return null;
}
@@ -215,12 +216,14 @@ public class CheckoutCommand extends GitCommand<Ref> {
throw new JGitInternalException(MessageFormat.format(JGitText
.get().checkoutUnexpectedResult, updateResult.name()));
+
if (!dco.getToBeDeleted().isEmpty()) {
- status = new CheckoutResult(Status.NONDELETED, dco
- .getToBeDeleted());
- }
- else
- status = CheckoutResult.OK_RESULT;
+ status = new CheckoutResult(Status.NONDELETED,
+ dco.getToBeDeleted());
+ } else
+ status = new CheckoutResult(new ArrayList<String>(dco
+ .getUpdated().keySet()), dco.getRemoved());
+
return ref;
} catch (IOException ioe) {
throw new JGitInternalException(ioe.getMessage(), ioe);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java
index 7366493..6a1bfb8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java
@@ -52,12 +52,6 @@ import java.util.List;
public class CheckoutResult {
/**
- * The {@link Status#OK} result;
- */
- public static final CheckoutResult OK_RESULT = new CheckoutResult(
- Status.OK, null);
-
- /**
* The {@link Status#ERROR} result;
*/
public static final CheckoutResult ERROR_RESULT = new CheckoutResult(
@@ -101,6 +95,23 @@ public class CheckoutResult {
private final List<String> undeletedList;
+ private final List<String> modifiedList;
+
+ private final List<String> removedList;
+
+ /**
+ * Create a new fail result. If status is {@link Status#CONFLICTS},
+ * <code>fileList</code> is a list of conflicting files, if status is
+ * {@link Status#NONDELETED}, <code>fileList</code> is a list of not deleted
+ * files. All other values ignore <code>fileList</code>. To create a result
+ * for {@link Status#OK}, see {@link #CheckoutResult(List, List)}.
+ *
+ * @param status
+ * the failure status
+ * @param fileList
+ * the list of files to store, status has to be either
+ * {@link Status#CONFLICTS} or {@link Status#NONDELETED}.
+ */
CheckoutResult(Status status, List<String> fileList) {
myStatus = status;
if (status == Status.CONFLICTS)
@@ -112,6 +123,26 @@ public class CheckoutResult {
else
this.undeletedList = new ArrayList<String>(0);
+ this.modifiedList = new ArrayList<String>(0);
+ this.removedList = new ArrayList<String>(0);
+ }
+
+ /**
+ * Create a new OK result with modified and removed files.
+ *
+ * @param modified
+ * the modified files
+ * @param removed
+ * the removed files.
+ */
+ CheckoutResult(List<String> modified, List<String> removed) {
+ myStatus = Status.OK;
+
+ this.conflictList = new ArrayList<String>(0);
+ this.undeletedList = new ArrayList<String>(0);
+
+ this.modifiedList = modified;
+ this.removedList = removed;
}
/**
@@ -138,4 +169,19 @@ public class CheckoutResult {
return undeletedList;
}
+ /**
+ * @return the list of files that where modified during checkout, or an
+ * empty list if {@link #getStatus()} is not {@link Status#OK}
+ */
+ public List<String> getModifiedList() {
+ return modifiedList;
+ }
+
+ /**
+ * @return the list of files that where removed during checkout, or an empty
+ * list if {@link #getStatus()} is not {@link Status#OK}
+ */
+ public List<String> getRemovedList() {
+ return removedList;
+ }
}