Browse Source

Merge "CheckoutResult: return paths instead of Files"

stable-0.11
Shawn Pearce 14 years ago committed by Code Review
parent
commit
4170913b1b
  1. 7
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
  2. 19
      org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
  3. 15
      org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java

7
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java

@ -128,9 +128,8 @@ public class CheckoutCommandTest extends RepositoryTestCase {
}
}
public void testCheckoutWithConflict() throws IOException {
public void testCheckoutWithConflict() {
CheckoutCommand co = git.checkout();
File trashFile = writeTrashFile("Test.txt", "Another change");
try {
writeTrashFile("Test.txt", "Another change");
assertEquals(Status.NOT_TRIED, co.getResult().getStatus());
@ -138,7 +137,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
fail("Should have failed");
} catch (Exception e) {
assertEquals(Status.CONFLICTS, co.getResult().getStatus());
assertTrue(co.getResult().getConflictList().contains(trashFile));
assertTrue(co.getResult().getConflictList().contains("Test.txt"));
}
}
@ -171,7 +170,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
co.setName("test").call();
assertTrue(testFile.exists());
assertEquals(Status.NONDELETED, co.getResult().getStatus());
assertTrue(co.getResult().getUndeletedList().contains(testFile));
assertTrue(co.getResult().getUndeletedList().contains("Test.txt"));
} finally {
fis.close();
}

19
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java

@ -42,11 +42,8 @@
*/
package org.eclipse.jgit.api;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.CheckoutResult.Status;
@ -141,11 +138,8 @@ public class CheckoutCommand extends GitCommand<Ref> {
try {
dco.checkout();
} catch (CheckoutConflictException e) {
List<File> fileList = new ArrayList<File>();
for (String filePath : dco.getConflicts()) {
fileList.add(new File(repo.getWorkTree(), filePath));
}
status = new CheckoutResult(Status.CONFLICTS, fileList);
status = new CheckoutResult(Status.CONFLICTS, dco
.getConflicts());
throw e;
}
Ref ref = repo.getRef(name);
@ -183,12 +177,9 @@ public class CheckoutCommand extends GitCommand<Ref> {
throw new JGitInternalException(MessageFormat.format(JGitText
.get().checkoutUnexpectedResult, updateResult.name()));
if (!repo.isBare() && !dco.getToBeDeleted().isEmpty()) {
List<File> fileList = new ArrayList<File>();
for (String filePath : dco.getToBeDeleted()) {
fileList.add(new File(repo.getWorkTree(), filePath));
}
status = new CheckoutResult(Status.NONDELETED, fileList);
if (!dco.getToBeDeleted().isEmpty()) {
status = new CheckoutResult(Status.NONDELETED, dco
.getToBeDeleted());
}
else
status = CheckoutResult.OK_RESULT;

15
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutResult.java

@ -42,7 +42,6 @@
*/
package org.eclipse.jgit.api;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -97,20 +96,20 @@ public class CheckoutResult {
private final Status myStatus;
private final List<File> conflictList;
private final List<String> conflictList;
private final List<File> undeletedList;
private final List<String> undeletedList;
CheckoutResult(Status status, List<File> fileList) {
CheckoutResult(Status status, List<String> fileList) {
myStatus = status;
if (status == Status.CONFLICTS)
this.conflictList = fileList;
else
this.conflictList = new ArrayList<File>(0);
this.conflictList = new ArrayList<String>(0);
if (status == Status.NONDELETED)
this.undeletedList = fileList;
else
this.undeletedList = new ArrayList<File>(0);
this.undeletedList = new ArrayList<String>(0);
}
@ -125,7 +124,7 @@ public class CheckoutResult {
* @return the list of files that created a checkout conflict, or an empty
* list if {@link #getStatus()} is not {@link Status#CONFLICTS};
*/
public List<File> getConflictList() {
public List<String> getConflictList() {
return conflictList;
}
@ -134,7 +133,7 @@ public class CheckoutResult {
* an empty list if {@link #getStatus()} is not
* {@link Status#NONDELETED};
*/
public List<File> getUndeletedList() {
public List<String> getUndeletedList() {
return undeletedList;
}

Loading…
Cancel
Save