import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
try {
if (checkoutAllPaths || !paths.isEmpty()) {
checkoutPaths();
- status = CheckoutResult.OK_RESULT;
+ status = new CheckoutResult(Status.OK, paths);
setCallable(false);
return null;
}
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);
*/
public class CheckoutResult {
- /**
- * The {@link Status#OK} result;
- */
- public static final CheckoutResult OK_RESULT = new CheckoutResult(
- Status.OK, null);
-
/**
* The {@link Status#ERROR} result;
*/
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)
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;
}
/**
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;
+ }
}