Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-03-17 15:09:30 +0000
committerThomas Wolf2019-03-18 22:05:36 +0000
commit8a668936f524a9c586e0096b17490192990aea60 (patch)
treeb54da776f9507e674882b31ae502d6cdfe20f1cd /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui
parent9e97a3c89932b04e32cb908f895e458dc045af02 (diff)
downloadegit-8a668936f524a9c586e0096b17490192990aea60.tar.gz
egit-8a668936f524a9c586e0096b17490192990aea60.tar.xz
egit-8a668936f524a9c586e0096b17490192990aea60.zip
Reset only conflicting paths in a checkout conflict
The two checkout conflict dialogs show only the conflicting files, but their "Reset" button then performed a reset --hard, also discarding changes on other files not shown in the dialog. This was highly unexpected. Change that reset button to only discard changes on the files shown in the dialog, i.e., the ones that caused a conflict in the first place. Use "Discard Changes" instead of "Reset" for the button text. Add a new test that verifies that non-conflicting changes are preserved. Bug: 545471 Change-Id: I4bc7045cc98b04fe6254cffe1fc44a64bb6e2d88 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java34
2 files changed, 41 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index 53c56ff0bd..a1b6f4e8f3 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -756,13 +756,17 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
}
protected String getTestFileContent() throws Exception {
+ return getTestFileContent(FILE1);
+ }
+
+ protected String getTestFileContent(String fileName) throws Exception {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
- .getFile(new Path("folder/test.txt"));
+ .getFolder(FOLDER).getFile(fileName);
if (file.exists()) {
byte[] bytes = IO.readFully(file.getLocation().toFile());
return new String(bytes, file.getCharset());
- } else
- return "";
+ }
+ return "";
}
/**
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index 9a984b58d2..65e0d934df 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -36,6 +36,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.op.TagOperation;
+import org.eclipse.egit.core.test.TestUtils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
@@ -130,6 +131,39 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
}
@Test
+ public void testCheckoutWithConflictsAndReset() throws Exception {
+ String charset = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(PROJ1).getDefaultCharset();
+ String file1Content = getTestFileContent();
+ checkoutAndVerify(new String[] { LOCAL_BRANCHES, "stable" });
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE1).setContents(
+ new ByteArrayInputStream(
+ "New content".getBytes(charset)),
+ IResource.NONE, null);
+ String file2Content = "Also changed";
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE2).setContents(
+ new ByteArrayInputStream(
+ file2Content.getBytes(charset)),
+ IResource.NONE, null);
+ checkout(new String[] { LOCAL_BRANCHES, "master" });
+ SWTBotShell showConflicts = bot
+ .shell(UIText.BranchResultDialog_CheckoutConflictsTitle);
+ SWTBot shellBot = showConflicts.bot();
+ SWTBotTreeItem[] items = shellBot.tree().getAllItems();
+ assertEquals(1, items.length);
+ assertEquals(FILE1, items[0].getItems()[0].getItems()[0].getText());
+ shellBot.button(UIText.BranchResultDialog_buttonDiscardChanges).click();
+ TestUtils.waitForJobs(500, 5000, JobFamilies.DISCARD_CHANGES);
+ TestUtil.joinJobs(JobFamilies.CHECKOUT);
+ assertEquals(file1Content, getTestFileContent());
+ // FILE2 should _not_ have been reset since it didn't conflict with the
+ // checkout and wasn't shown in the conflict dialog
+ assertEquals(file2Content, getTestFileContent(FILE2));
+ }
+
+ @Test
public void testCheckoutWithNonDeleted() throws Exception {
// we need to check if this file system has problems to
// delete a file with an open FileInputStrem

Back to the top