Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2011-02-08 18:39:37 -0500
committerDariusz Luksza2011-02-08 19:59:21 -0500
commit8f65c45738b5dfe346ff9a771b865eb41cc57f1b (patch)
treea42b1c1cb3fc4fc3c8bc1c8f7a32c50147dc9540
parentc563d5161304f968b577f28577a103deeb25194d (diff)
downloadegit-8f65c45738b5dfe346ff9a771b865eb41cc57f1b.tar.gz
egit-8f65c45738b5dfe346ff9a771b865eb41cc57f1b.tar.xz
egit-8f65c45738b5dfe346ff9a771b865eb41cc57f1b.zip
[sync] Fix deleted files in sync-view
Deleted files were not shown in synchronize view because we check object type only in actual tree. Now if object type in actual tree is OBJ_BAD we try to get its type from base and ancestor tree. Bug:336652 Change-Id: Ib3e9fe18b2531dc84cb55788a76f66a131e544c1 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/SynchronizeViewTest.java47
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelBlob.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelObjectContainer.java9
3 files changed, 77 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/SynchronizeViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/SynchronizeViewTest.java
index cb16a981e..8da3a4367 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/SynchronizeViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/SynchronizeViewTest.java
@@ -15,6 +15,8 @@ import static org.junit.Assert.assertEquals;
import java.io.File;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIText;
@@ -176,6 +178,40 @@ public class SynchronizeViewTest extends LocalRepositoryTestCase {
assertEquals(1, syncViewTree.getAllItems().length);
}
+ @Test
+ public void shouldListFileDeletedChange() throws Exception {
+ // given
+ resetRepository(PROJ1);
+ createTag(PROJ1, "base");
+ deleteFileAndCommit(PROJ1);
+ showDialog(PROJ1, "Team", "Synchronize...");
+
+ // when
+ bot.shell("Synchronize repository: " + REPO1 + File.separator + ".git")
+ .activate();
+
+ bot.comboBox(2)
+ .setSelection(UIText.SynchronizeWithAction_tagsName);
+ bot.comboBox(3).setSelection("base");
+
+ // fire action
+ bot.button(IDialogConstants.OK_LABEL).click();
+
+ // then
+ SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
+ assertEquals(1, syncViewTree.getAllItems().length);
+ SWTBotTreeItem commitTree = syncViewTree.getAllItems()[0];
+ commitTree.expand();
+ SWTBotTreeItem projectTree = commitTree.getItems()[0];
+ projectTree.expand();
+ assertEquals(1, projectTree.getItems().length);
+ SWTBotTreeItem folderTree = projectTree.getItems()[0];
+ folderTree.expand();
+ assertEquals(1, folderTree.getItems().length);
+ SWTBotTreeItem fileTree = folderTree.getItems()[0];
+ assertEquals("test.txt", fileTree.getText());
+ }
+
private void waitUntilTreeHasNodeWithText(final SWTBotTree tree,
final String text) {
bot.waitUntil(new ICondition() {
@@ -308,6 +344,17 @@ public class SynchronizeViewTest extends LocalRepositoryTestCase {
changeFilesInProject();
Thread.sleep(1000); // wait 1 s to get different time stamps
// TODO can be removed when commit is based on DirCache
+ commit(projectName);
+ }
+
+ private void deleteFileAndCommit(String projectName) throws Exception {
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFile(new Path("folder/test.txt")).delete(true, null);
+
+ commit(projectName);
+ }
+
+ private void commit(String projectName) throws InterruptedException {
showDialog(projectName, "Team", UIText.CommitAction_commit);
bot.shell(UIText.CommitDialog_CommitChanges).bot().activeShell();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelBlob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelBlob.java
index 71df9224a..d2bf64444 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelBlob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelBlob.java
@@ -8,8 +8,12 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.synchronize.model;
+import static org.eclipse.compare.structuremergeviewer.Differencer.ADDITION;
+import static org.eclipse.compare.structuremergeviewer.Differencer.CHANGE;
+import static org.eclipse.compare.structuremergeviewer.Differencer.DELETION;
import static org.eclipse.compare.structuremergeviewer.Differencer.LEFT;
import static org.eclipse.compare.structuremergeviewer.Differencer.RIGHT;
+import static org.eclipse.jgit.lib.ObjectId.zeroId;
import java.io.IOException;
@@ -118,6 +122,24 @@ public class GitModelBlob extends GitModelCommit {
}
@Override
+ public int getKind() {
+ if (kind != LEFT && kind != RIGHT)
+ return kind;
+
+ int changeKind;
+ if (zeroId().equals(remoteId))
+ changeKind = DELETION;
+ else if (zeroId().equals(ancestorId))
+ changeKind = ADDITION;
+ else
+ changeKind = CHANGE;
+
+ kind |= changeKind;
+
+ return kind;
+ }
+
+ @Override
public void prepareInput(CompareConfiguration configuration,
IProgressMonitor monitor) throws CoreException {
createCompareInput();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelObjectContainer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelObjectContainer.java
index 4a0cfc616..5168f2e50 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelObjectContainer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelObjectContainer.java
@@ -38,7 +38,10 @@ import org.eclipse.team.ui.mapping.SaveableComparison;
public abstract class GitModelObjectContainer extends GitModelObject implements
ISynchronizationCompareInput {
- private int kind = -1;
+ /**
+ * Describe what kind of change is connected with this object
+ */
+ protected int kind = -1;
private String name;
@@ -217,6 +220,10 @@ public abstract class GitModelObjectContainer extends GitModelObject implements
else
objAncestorId = ObjectId.zeroId();
int objectType = tw.getFileMode(actualNth).getObjectType();
+ if (objectType == Constants.OBJ_BAD)
+ objectType = tw.getFileMode(baseNth).getObjectType();
+ if (objectType == Constants.OBJ_BAD && ancestorNth > -1)
+ objectType = tw.getFileMode(ancestorNth).getObjectType();
if (objectType == Constants.OBJ_BLOB)
return new GitModelBlob(this, getBaseCommit(), ancestorCommit,

Back to the top