Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-04-07 11:12:39 +0000
committerMatthias Sohn2016-04-07 11:12:59 +0000
commit587fafd588f9cb429a8d740ba9abc9d766a570b9 (patch)
tree8de7005f39089cbadfbd21c73ccb18e444b0e86a
parentc02cd196b41da3bbe241d108e5f196149b386c81 (diff)
parentfbe70bcf1fb6dfd0fbb661653d625de78e0698eb (diff)
downloadegit-587fafd588f9cb429a8d740ba9abc9d766a570b9.tar.gz
egit-587fafd588f9cb429a8d740ba9abc9d766a570b9.tar.xz
egit-587fafd588f9cb429a8d740ba9abc9d766a570b9.zip
Merge branch 'master' into stable-4.3
* master: For asynchronous dialogs, use the topmost modal shell Fix compile error in GitCompareFileRevisionEditorInput When running "Commit" action open staging view instead of commit dialog Auto-switch between horizontal and vertical StagingView layout Move EclipseAuthenticator and EclipseProxySelector to egit.core Move EclipseSshSessionFactory to org.eclipse.egit.core Diff error message should mention that the error is from Git Distinguish unchanged/deleted files in logical models Change-Id: I196cb3158eca8e6a2aca60dba7d47085a6ad8997 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java152
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java16
-rw-r--r--org.eclipse.egit.core/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java33
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseAuthenticator.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseAuthenticator.java)2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseProxySelector.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java)2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseSshSessionFactory.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseSshSessionFactory.java)11
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSyncCache.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntry.java96
-rw-r--r--org.eclipse.egit.ui.test/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java9
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java7
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java4
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java64
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultDialog.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultDialog.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java57
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties3
27 files changed, 462 insertions, 117 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index ec2398121a..7c0614c216 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2010, Dariusz Luksza <dariusz@luksza.org>
+ * Copyright (C) 2010, 2015 Dariusz Luksza <dariusz@luksza.org> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -14,15 +14,22 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
@@ -31,12 +38,15 @@ import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.egit.core.test.TestProject;
import org.eclipse.egit.core.test.TestRepository;
+import org.eclipse.egit.core.test.models.SampleModelProvider;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.IResourceVariantTree;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -220,6 +230,146 @@ public class GitResourceVariantTreeTest extends GitTestCase {
assertNull(grvt.getResourceVariant(mainJava));
}
+ @Test
+ public void shouldNotReturnNullOnSameResouceVariant() throws Exception {
+ String modifiedFileName = "changingFile."
+ + SampleModelProvider.SAMPLE_FILE_EXTENSION;
+ String unchangedFileName = "notChangingFile."
+ + SampleModelProvider.SAMPLE_FILE_EXTENSION;
+ String removedFileName = "toBeRemovedFile."
+ + SampleModelProvider.SAMPLE_FILE_EXTENSION;
+
+ File modifiedFile = testRepo.createFile(iProject, modifiedFileName);
+ File unchangedFile = testRepo.createFile(iProject, unchangedFileName);
+ File removedFile = testRepo.createFile(iProject, removedFileName);
+
+ testRepo.appendFileContent(modifiedFile, "My content is changing");
+ testRepo.appendFileContent(unchangedFile, "My content is constant");
+ testRepo.appendFileContent(removedFile, "I will be removed");
+
+ IFile iModifiedFile = testRepo.getIFile(iProject, modifiedFile);
+ IFile iUnchangedFile = testRepo.getIFile(iProject, unchangedFile);
+ IFile iRemovedFile = testRepo.getIFile(iProject, removedFile);
+
+ testRepo.trackAllFiles(iProject);
+
+ RevCommit firstCommit = testRepo.commit("C1");
+
+ testRepo.appendFileContent(modifiedFile, " My content has changed");
+ testRepo.track(modifiedFile);
+ testRepo.removeFromIndex(removedFile);
+
+ RevCommit secondCommit = testRepo.commit("C2");
+
+ //@formatter:off
+ // History (X means has changed)
+ //------------------------------------------------------------
+ // files C1 [HEAD] C2
+ // changingFile.sample |-----X----------|-------X-------|->
+ // notChangingFile.sample |-----X----------|---------------|->
+ // toBeRemovedFile.sample |-----X----------|-------X-------|->
+ //-------------------------------------------------------------
+ //@formatter:on
+
+ testRepo.checkoutBranch(firstCommit.getName());
+
+ iProject.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+
+ // Now synchronize the two commits using our logical model provider
+ SampleModelProvider provider = new SampleModelProvider();
+ // Get the affected resources
+ ResourceMapping[] mappings = provider
+ .getMappings(iModifiedFile,
+ ResourceMappingContext.LOCAL_CONTEXT,
+ new NullProgressMonitor());
+
+ Set<IResource> includedResource = collectResources(mappings);
+ Set<IResource> expectedIncludedResources = new HashSet<IResource>();
+ expectedIncludedResources.add(iModifiedFile);
+ expectedIncludedResources.add(iUnchangedFile);
+ expectedIncludedResources.add(iRemovedFile);
+
+ assertEquals(expectedIncludedResources, includedResource);
+
+ // Synchronize the data
+ final GitSynchronizeData data = new GitSynchronizeData(
+ testRepo.getRepository(), firstCommit.getName(),
+ secondCommit.getName(), true, includedResource);
+ GitSynchronizeDataSet gitSynchDataSet = new GitSynchronizeDataSet(data);
+ final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(
+ gitSynchDataSet);
+ subscriber.init(new NullProgressMonitor());
+
+ IResourceVariantTree sourceVariantTree = subscriber.getSourceTree();
+ assertNotNull(sourceVariantTree);
+
+ IResourceVariantTree remoteVariantTree = subscriber.getRemoteTree();
+ assertNotNull(remoteVariantTree);
+
+ // In the use case in which the file has been deleted the source variant is
+ // not null whereas the remote variant is null.It seems quite logic.
+ // However in the second use case we have the same result, the source variant is
+ // not null whereas the remote is null. In both cases the null value does
+ // not mean the same thing. In the first case, the null value means that
+ // the resource is no longer in the repository and in the second the
+ // null value means there is no change between the two versions.
+ // Using these values I am not able to distinguish both case.
+ // It is in contradiction with test #shouldReturnNullResourceVariant2()
+ // and test #shoulReturnSameResourceVariant(). However I haven't found
+ // another way to handle this case. Maybe something can be
+ // done with ThreeWayDiffEntry.scan(tw) to force including in the cache
+ // some entry even if they have not changed. For example,
+ // ThreeWayDiffEntry.scan(tw,includedSource) or maybe try preventing the variant
+ // tree to return null by walking throught the repository and looking for the file...
+
+ IResourceVariant unchangedSourceVariant = sourceVariantTree
+ .getResourceVariant(iUnchangedFile);
+ IResourceVariant unchangedRemoteVariant = remoteVariantTree
+ .getResourceVariant(iUnchangedFile);
+
+ assertNotNull(unchangedSourceVariant);
+ assertNotNull(unchangedRemoteVariant);
+
+ IResourceVariant removedSourceVariant = sourceVariantTree
+ .getResourceVariant(iRemovedFile);
+ IResourceVariant removedRemoteVariant = remoteVariantTree
+ .getResourceVariant(iRemovedFile);
+
+ assertNotNull(removedSourceVariant);
+ assertNull(removedRemoteVariant);
+
+ GitSubscriberResourceMappingContext context = new GitSubscriberResourceMappingContext(subscriber, gitSynchDataSet);
+ assertFalse(context.hasLocalChange(iUnchangedFile,
+ new NullProgressMonitor()));
+ assertFalse(context.hasRemoteChange(iUnchangedFile,
+ new NullProgressMonitor()));
+
+ assertFalse(context.hasLocalChange(iModifiedFile,
+ new NullProgressMonitor()));
+ assertTrue(context.hasRemoteChange(iModifiedFile,
+ new NullProgressMonitor()));
+
+ assertFalse(context.hasLocalChange(iRemovedFile,
+ new NullProgressMonitor()));
+ assertTrue(context.hasRemoteChange(iRemovedFile,
+ new NullProgressMonitor()));
+ }
+
+ private static Set<IResource> collectResources(ResourceMapping[] mappings)
+ throws CoreException {
+ final Set<IResource> resources = new HashSet<IResource>();
+ ResourceMappingContext context = ResourceMappingContext.LOCAL_CONTEXT;
+ for (ResourceMapping mapping : mappings) {
+ ResourceTraversal[] traversals = mapping.getTraversals(context,
+ new NullProgressMonitor());
+ for (ResourceTraversal traversal : traversals) {
+ resources.addAll(Arrays.asList(traversal.getResources()));
+ }
+ }
+ return resources;
+ }
+
/**
* Create and commit Main.java file in master branch, then create branch
* "test" checkout nearly created branch and modify Main.java file.
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index 62ecd00fe0..1eccf133f8 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -3,6 +3,7 @@
* Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
* Copyright (C) 2012, Robin Stocker <robin@nibor.org>
* Copyright (C) 2012, Fran├žois Rey <eclipse.org_@_francois_._rey_._name>
+ * Copyright (C) 2015, Obeo
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -362,6 +363,21 @@ public class TestRepository {
}
/**
+ * Remove the given resource form the index.
+ *
+ * @param file
+ * @throws NoFilepatternException
+ * @throws GitAPIException
+ */
+ public void removeFromIndex(File file) throws NoFilepatternException, GitAPIException {
+ String repoPath = getRepoRelativePath(new Path(file.getPath())
+ .toString());
+ try (Git git = new Git(repository)) {
+ git.rm().addFilepattern(repoPath).call();
+ }
+ }
+
+ /**
* Appends content to end of given file.
*
* @param file
diff --git a/org.eclipse.egit.core/META-INF/MANIFEST.MF b/org.eclipse.egit.core/META-INF/MANIFEST.MF
index e166277107..ca683dafc6 100644
--- a/org.eclipse.egit.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.core/META-INF/MANIFEST.MF
@@ -41,7 +41,9 @@ Export-Package: org.eclipse.egit.core;version="4.3.0";
org.eclipse.egit.core.synchronize.dto;version="4.3.0";x-friends:="org.eclipse.egit.ui"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Import-Package: org.eclipse.jgit.annotations;version="[4.3.0,4.4.0)",
+Import-Package: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)",
+ org.eclipse.core.net.proxy;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.jgit.annotations;version="[4.3.0,4.4.0)",
org.eclipse.jgit.api;version="[4.3.0,4.4.0)",
org.eclipse.jgit.api.errors;version="[4.3.0,4.4.0)",
org.eclipse.jgit.diff;version="[4.3.0,4.4.0)",
@@ -61,5 +63,6 @@ Import-Package: org.eclipse.jgit.annotations;version="[4.3.0,4.4.0)",
org.eclipse.jgit.treewalk.filter;version="[4.3.0,4.4.0)",
org.eclipse.jgit.util;version="[4.3.0,4.4.0)",
org.eclipse.jgit.util.io;version="[4.3.0,4.4.0)",
+ org.eclipse.jsch.core;bundle-version="[1.1.100,2.0.0)",
org.slf4j;version="[1.7.0,2.0.0)"
Eclipse-ExtensibleAPI: true
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index 8eb51d2642..8bee0b46e1 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -9,6 +9,8 @@ package org.eclipse.egit.core;
import java.io.File;
import java.io.IOException;
+import java.net.Authenticator;
+import java.net.ProxySelector;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
@@ -21,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -60,12 +63,15 @@ import org.eclipse.egit.core.securestorage.EGitSecureStore;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.util.FS;
+import org.eclipse.jsch.core.IJSchService;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The plugin class for the org.eclipse.egit.core plugin. This
@@ -176,6 +182,9 @@ public class Activator extends Plugin implements DebugOptionsListener {
context.registerService(DebugOptionsListener.class.getName(), this,
props);
+ setupSSH(context);
+ setupProxy(context);
+
repositoryCache = new RepositoryCache();
indexDiffCache = new IndexDiffCache();
try {
@@ -195,6 +204,30 @@ public class Activator extends Plugin implements DebugOptionsListener {
registerMergeStrategyRegistryListener();
}
+ @SuppressWarnings("unchecked")
+ private void setupSSH(final BundleContext context) {
+ final ServiceReference ssh;
+
+ ssh = context.getServiceReference(IJSchService.class.getName());
+ if (ssh != null) {
+ SshSessionFactory.setInstance(new EclipseSshSessionFactory(
+ (IJSchService) context.getService(ssh)));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setupProxy(final BundleContext context) {
+ final ServiceReference proxy;
+
+ proxy = context.getServiceReference(IProxyService.class.getName());
+ if (proxy != null) {
+ ProxySelector.setDefault(new EclipseProxySelector(
+ (IProxyService) context.getService(proxy)));
+ Authenticator.setDefault(new EclipseAuthenticator(
+ (IProxyService) context.getService(proxy)));
+ }
+ }
+
private void registerPreDeleteResourceChangeListener() {
if (preDeleteProjectListener == null) {
preDeleteProjectListener = new IResourceChangeListener() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseAuthenticator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseAuthenticator.java
index 0aebe09c1c..5d95215b0e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseAuthenticator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseAuthenticator.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui;
+package org.eclipse.egit.core;
import java.net.Authenticator;
import java.net.InetAddress;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseProxySelector.java
index 156dd8c92c..7f66803e9e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseProxySelector.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui;
+package org.eclipse.egit.core;
import java.io.IOException;
import java.net.InetAddress;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseSshSessionFactory.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseSshSessionFactory.java
index d2d8cc37cd..43dd9366ef 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseSshSessionFactory.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseSshSessionFactory.java
@@ -8,13 +8,14 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui;
+package org.eclipse.egit.core;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.CredentialsProviderUserInfo;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jsch.core.IJSchService;
-import org.eclipse.jsch.ui.UserInfoPrompter;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
@@ -59,7 +60,9 @@ class EclipseSshSessionFactory extends JschConfigSessionFactory {
@Override
protected void configure(final OpenSshConfig.Host hc, final Session session) {
UserInfo userInfo = session.getUserInfo();
- if (!hc.isBatchMode() && userInfo == null)
- new UserInfoPrompter(session);
+ if (!hc.isBatchMode() && userInfo == null) {
+ final CredentialsProvider cp = CredentialsProvider.getDefault();
+ session.setUserInfo(new CredentialsProviderUserInfo(session, cp));
+ }
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSyncCache.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSyncCache.java
index c34177c9a9..af7d7ef993 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSyncCache.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSyncCache.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2011, 2013 Dariusz Luksza <dariusz@luksza.org> and others.
+ * Copyright (C) 2011, 2015 Dariusz Luksza <dariusz@luksza.org> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -152,8 +152,8 @@ class GitSyncCache {
tw.addTree(dci);
fti.setDirCacheIterator(tw, 3);
}
- List<ThreeWayDiffEntry> diffEntrys = ThreeWayDiffEntry.scan(tw);
-
+ List<ThreeWayDiffEntry> diffEntrys = ThreeWayDiffEntry
+ .scan(tw, gsd);
for (ThreeWayDiffEntry diffEntry : diffEntrys)
repoCache.addMember(diffEntry);
} catch (Exception e) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntry.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntry.java
index d3175e3e6a..7adaff169f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntry.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/ThreeWayDiffEntry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2011, Dariusz Luksza <dariusz@luksza.org>
+ * Copyright (C) 2011, 2015 Dariusz Luksza <dariusz@luksza.org> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,8 +10,16 @@ package org.eclipse.egit.core.synchronize;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.AbbreviatedObjectId;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.MutableObjectId;
@@ -64,20 +72,45 @@ public final class ThreeWayDiffEntry {
}
/**
- * Converts the TreeWalk into TreeWayDiffEntry headers.
+ * Convert the TreeWalk into {@link ThreeWayDiffEntry} instances.
*
* @param walk
- * the TreeWalk to walk through. Must have exactly three trees in
- * this order: local, base and remote and can't be recursive.
- * @return headers describing the changed file.
+ * the TreeWalk to walk through. Must have 3 or 4 trees in this
+ * order: local, base, remote, optionally a DirCacheIterator, and
+ * can't be recursive.
+ * @return A list, never null but possibly empty, of
+ * {@link ThreeWayDiffEntry} describing the changed file.
* @throws IOException
* the repository cannot be accessed.
* @throws IllegalArgumentException
- * when {@code walk} doen't have exactly three trees, or when
+ * when {@code walk} doen't have 3 or 4 trees, or when
* {@code walk} is recursive
*/
- public static List<ThreeWayDiffEntry> scan(TreeWalk walk)
+ public static @NonNull List<ThreeWayDiffEntry> scan(TreeWalk walk)
throws IOException {
+ return scan(walk, null);
+ }
+
+ /**
+ * Convert the TreeWalk into {@link ThreeWayDiffEntry} instances.
+ *
+ * @param walk
+ * the TreeWalk to walk through. Must have 3 or 4 trees in this
+ * order: local, base, remote, optionally a DirCacheIterator, and
+ * can't be recursive.
+ * @param gsd
+ * The {@link GitSynchronizeData} that contains info about the
+ * synchronization configuration and scope.
+ * @return A list, never null but possibly empty, of
+ * {@link ThreeWayDiffEntry} describing the changed file.
+ * @throws IOException
+ * the repository cannot be accessed.
+ * @throws IllegalArgumentException
+ * when {@code walk} doen't have 3 or 4 trees, or when
+ * {@code walk} is recursive
+ */
+ public static @NonNull List<ThreeWayDiffEntry> scan(TreeWalk walk,
+ GitSynchronizeData gsd) throws IOException {
if (walk.getTreeCount() != 3 && walk.getTreeCount() != 4)
throw new IllegalArgumentException(
"TreeWalk need to have three or four trees"); //$NON-NLS-1$
@@ -87,6 +120,7 @@ public final class ThreeWayDiffEntry {
List<ThreeWayDiffEntry> r = new ArrayList<ThreeWayDiffEntry>();
MutableObjectId idBuf = new MutableObjectId();
+ NeedEntry needEntry = new NeedEntry(gsd);
while (walk.next()) {
ThreeWayDiffEntry e = new ThreeWayDiffEntry();
@@ -101,8 +135,15 @@ public final class ThreeWayDiffEntry {
boolean localSameAsBase = e.localId.equals(e.baseId);
if (!A_ZERO.equals(e.localId) && localSameAsBase
- && e.baseId.equals(e.remoteId))
+ && e.baseId.equals(e.remoteId)) {
+ if (needEntry.apply(walk.getPathString())) {
+ e.direction = Direction.INCOMING;
+ e.changeType = ChangeType.IN_SYNC;
+ e.path = walk.getPathString();
+ r.add(e);
+ }
continue;
+ }
e.path = walk.getPathString();
boolean localIsMissing = walk.getFileMode(0) == FileMode.MISSING;
@@ -223,4 +264,43 @@ public final class ThreeWayDiffEntry {
return buf.toString();
}
+ private static class NeedEntry {
+ private final GitSynchronizeData gsd;
+
+ private Set<String> paths;
+
+ public NeedEntry(GitSynchronizeData gsd) {
+ this.gsd = gsd;
+ }
+
+ boolean apply(String pathString) {
+ if (gsd == null) {
+ // This means that all paths must be included
+ return true;
+ }
+ if (paths == null) {
+ initPaths();
+ }
+ return paths.contains(pathString);
+ }
+
+ private void initPaths() {
+ Set<IResource> resources = gsd.getIncludedResources();
+ if (resources != null && !resources.isEmpty()) {
+ paths = new HashSet<String>(resources.size());
+ final Path repositoryPath = new Path(gsd.getRepository()
+ .getWorkTree().getAbsolutePath());
+ for (IResource resource : gsd.getIncludedResources()) {
+ IPath resourceLocation = resource.getLocation();
+ if (resourceLocation != null) {
+ paths.add(resourceLocation.makeRelativeTo(
+ repositoryPath).toString());
+ }
+ }
+ } else {
+ paths = Collections.emptySet();
+ }
+ }
+ }
+
}
diff --git a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
index 88c0eac8ad..14979fa7fc 100644
--- a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.apache.log4j;bundle-version="[1.0.0,2.0.0)",
org.mockito;bundle-version="[1.8.0,1.9.0)",
org.objenesis;bundle-version="[1.0.0,2.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.8.0,4.0.0)"
-Import-Package: org.eclipse.egit.core.test;version="[4.3.0,4.4.0)",
+Import-Package: org.eclipse.core.net.proxy;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.egit.core.test;version="[4.3.0,4.4.0)",
org.eclipse.egit.gitflow;version="[4.3.0,4.4.0)",
org.eclipse.egit.gitflow.op;version="[4.3.0,4.4.0)",
org.eclipse.egit.gitflow.ui;version="[4.3.0,4.4.0)",
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
index 9841403997..7ff323e2b7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
@@ -35,6 +35,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,6 +49,8 @@ public class CommitActionTest extends LocalRepositoryTestCase {
@Before
public void setup() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
repositoryFile = createProjectAndCommitToRepository();
Repository repo = lookupRepository(repositoryFile);
TestUtil.configureTestCommitterAsUser(repo);
@@ -59,6 +62,12 @@ public class CommitActionTest extends LocalRepositoryTestCase {
assertTrue(dotProject.delete());
}
+ @After
+ public void tearDown() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
+ }
+
@Test
public void testOpenCommitWithoutChanged() throws Exception {
NoFilesToCommitPopup popup = CommitDialogTester
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
index 8f79fda5ec..91e13cae07 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
@@ -17,6 +17,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.repository.RepositoriesView;
@@ -29,6 +30,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,6 +46,8 @@ public class CommitNonWSChangesTest extends LocalRepositoryTestCase {
@Before
public void setup() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
repositoryFile = createProjectAndCommitToRepository();
Activator.getDefault().getRepositoryUtil()
.addConfiguredRepository(repositoryFile);
@@ -51,6 +55,12 @@ public class CommitNonWSChangesTest extends LocalRepositoryTestCase {
.getRepositoryCache().lookupRepository(repositoryFile);
}
+ @After
+ public void tearDown() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
+ }
+
@Test
public void testCommitDeletedProject() throws Exception {
IProject project = ResourcesPlugin.getWorkspace().getRoot()
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
index 89a9fbf4ca..b9cda2da93 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
@@ -32,6 +32,7 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffCache;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.RepositoryCacheRule;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.test.ContextMenuHelper;
@@ -144,6 +145,9 @@ public class GitRepositoriesViewRepoDeletionTest extends
@Test
public void testRemoveRepositoryRemoveFromCachesBug483664()
throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
+
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
@@ -264,6 +268,9 @@ public class GitRepositoriesViewRepoDeletionTest extends
configuredRepos.isEmpty());
assertEquals("Expected no cached repositories", "[]", results[0]);
assertEquals("Expected no IndexDiffCache entries", "[]", results[1]);
+
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
}
@Test
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index d47ecb4bc5..7196648991 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -32,6 +32,7 @@ import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
@@ -190,6 +191,8 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
*/
@Test
public void testContextMenuRepository() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
// We just check if the dialogs open, the actual commit and import projects
// is tested elsewhere
SWTBotTree tree = getOrOpenView().bot().tree();
@@ -202,6 +205,8 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
myUtil.getPluginLocalizedValue("RepoViewImportProjects.label"),
NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle,
repositoryFile));
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
}
/**
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
index b50a8a479e..83a1f60b0e 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
@@ -83,11 +83,15 @@ public abstract class AbstractSynchronizeViewTest extends
@Before
public void setupViews() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
TestUtil.showExplorerView();
}
@After
public void closeSynchronizeView() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
TestUtil.hideView(ISynchronizeView.VIEW_ID);
}
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index 872383f1cb..e3e15ad8a9 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -9,7 +9,6 @@ Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.net;bundle-version="[1.1.0,2.0.0)",
org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.team.core;bundle-version="[3.6.100,4.0.0)",
@@ -19,10 +18,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.4.0,4.0.0)",
org.eclipse.compare;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jsch.ui;bundle-version="[1.1.100,2.0.0)",
- org.eclipse.jsch.core;bundle-version="[1.1.100,2.0.0)",
org.eclipse.ui.editors;bundle-version="[3.4.0,4.0.0)",
- com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)",
org.eclipse.ui.navigator;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
index 1d37155c71..79b4c1941f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
@@ -15,8 +15,6 @@ package org.eclipse.egit.ui;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.net.Authenticator;
-import java.net.ProxySelector;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -25,7 +23,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
@@ -62,8 +59,6 @@ import org.eclipse.jgit.events.ListenerHandle;
import org.eclipse.jgit.events.RepositoryEvent;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.CredentialsProvider;
-import org.eclipse.jgit.transport.SshSessionFactory;
-import org.eclipse.jsch.core.IJSchService;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.swt.graphics.Font;
@@ -75,7 +70,6 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.ui.themes.ITheme;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
/**
* This is a plugin singleton mostly controlling logging.
@@ -311,8 +305,6 @@ public class Activator extends AbstractUIPlugin implements DebugOptionsListener
context.registerService(DebugOptionsListener.class.getName(), this,
props);
- setupSSH(context);
- setupProxy(context);
setupRepoChangeScanner();
setupRepoIndexRefresh();
setupFocusHandling();
@@ -683,29 +675,6 @@ public class Activator extends AbstractUIPlugin implements DebugOptionsListener
rcs.schedule(RepositoryChangeScanner.REPO_SCAN_INTERVAL);
}
- @SuppressWarnings("unchecked")
- private void setupSSH(final BundleContext context) {
- final ServiceReference ssh;
-
- ssh = context.getServiceReference(IJSchService.class.getName());
- if (ssh != null) {
- SshSessionFactory.setInstance(new EclipseSshSessionFactory(
- (IJSchService) context.getService(ssh)));
- }
- }
-
- private void setupProxy(final BundleContext context) {
- final ServiceReference proxy;
-
- proxy = context.getServiceReference(IProxyService.class.getName());
- if (proxy != null) {
- ProxySelector.setDefault(new EclipseProxySelector(
- (IProxyService) context.getService(proxy)));
- Authenticator.setDefault(new EclipseAuthenticator(
- (IProxyService) context.getService(proxy)));
- }
- }
-
@Override
public void stop(final BundleContext context) throws Exception {
if (refreshHandle != null) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
index 6dc1e80ab7..ae8ab39eb1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
@@ -92,6 +92,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(UIPreferences.FINDTOOLBAR_IGNORE_CASE, true);
store.setDefault(UIPreferences.FINDTOOLBAR_FIND_IN,
FindToolbar.PREFS_FINDIN_ALL);
+ store.setDefault(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY, false);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
index 9ea9fa7fc4..6486701c40 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
@@ -67,6 +67,8 @@ public class UIPreferences {
/** */
public final static String COMMIT_DIALOG_HARD_WRAP_MESSAGE = "commit_dialog_hard_wrap_message"; //$NON-NLS-1$
/** */
+ public final static String ALWAYS_USE_STAGING_VIEW = "always_use_staging_view"; //$NON-NLS-1$
+ /** */
public final static String COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE = "commit_dialog_warn_about_message_second_line"; //$NON-NLS-1$
/** */
public final static String COMMIT_DIALOG_SIGNED_OFF_BY = "commit_dialog_signed_off_by"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 598afec4be..cadf297e01 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -3207,6 +3207,9 @@ public class UIText extends NLS {
public static String CommittingPreferencePage_BlockCommitCombo;
/** */
+ public static String CommittingPreferencePage_AlwaysUseStagingView;
+
+ /** */
public static String DateFormatPreferencePage_title;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
index 56311c134e..729e805188 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
@@ -19,11 +19,16 @@ package org.eclipse.egit.ui.internal.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.commit.CommitUI;
import org.eclipse.egit.ui.internal.operations.GitScopeUtil;
+import org.eclipse.egit.ui.internal.staging.StagingView;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
/**
* Scan for modified resources in the same project as the selected resources.
@@ -32,27 +37,48 @@ public class CommitActionHandler extends RepositoryActionHandler {
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
- final Repository repo = getRepository(true, event);
- if (repo == null)
- return null;
- final Shell shell = getShell(event);
- IResource[] resourcesInScope;
- try {
- IResource[] selectedResources = getSelectedResources(event);
- if (selectedResources.length > 0) {
- IWorkbenchPart part = getPart(event);
- resourcesInScope = GitScopeUtil.getRelatedChanges(part,
- selectedResources);
- } else
- resourcesInScope = new IResource[0];
- } catch (InterruptedException e) {
- // ignore, we will not show the commit dialog in case the user
- // cancels the scope operation
+
+ final Repository repository = getRepository(true, event);
+ if (repository == null) {
return null;
}
- CommitUI commitUi = new CommitUI(shell, repo, resourcesInScope,
- false);
- commitUi.commit();
+ boolean useStagingView = Activator.getDefault().getPreferenceStore()
+ .getBoolean(UIPreferences.ALWAYS_USE_STAGING_VIEW);
+ if (useStagingView) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ StagingView view = (StagingView) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .showView(StagingView.VIEW_ID);
+ view.setFocus();
+ } catch (PartInitException e) {
+ Activator.logError(e.getMessage(), e);
+ }
+ }
+ });
+ } else {
+ final Shell shell = getShell(event);
+ IResource[] resourcesInScope;
+ try {
+ IResource[] selectedResources = getSelectedResources(event);
+ if (selectedResources.length > 0) {
+ IWorkbenchPart part = getPart(event);
+ resourcesInScope = GitScopeUtil.getRelatedChanges(part,
+ selectedResources);
+ } else
+ resourcesInScope = new IResource[0];
+ } catch (InterruptedException e) {
+ // ignore, we will not show the commit dialog in case the user
+ // cancels the scope operation
+ return null;
+ }
+ CommitUI commitUi = new CommitUI(shell, repository,
+ resourcesInScope, false);
+ commitUi.commit();
+ }
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultDialog.java
index 35469438c0..afecb95299 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultDialog.java
@@ -68,16 +68,10 @@ public class FetchResultDialog extends TitleAreaDialog {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- PlatformUI.getWorkbench().getDisplay().asyncExec(
- new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- new FetchResultDialog(shell, repository,
- result, sourceString).open();
- }
- });
+ Shell shell = PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell();
+ new FetchResultDialog(shell, repository, result, sourceString)
+ .open();
}
});
}
@@ -117,8 +111,9 @@ public class FetchResultDialog extends TitleAreaDialog {
@Override
public void run() {
Dialog dlg = SimpleConfigureFetchDialog.getDialog(
- PlatformUI.getWorkbench().getDisplay()
- .getActiveShell(), localDb);
+ PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell(),
+ localDb);
dlg.open();
}
});
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
index f86601bccd..28d8e49e56 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
@@ -64,6 +64,11 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage
protected void createFieldEditors() {
Composite main = getFieldEditorParent();
+ BooleanFieldEditor useStagingView = new BooleanFieldEditor(
+ UIPreferences.ALWAYS_USE_STAGING_VIEW,
+ UIText.CommittingPreferencePage_AlwaysUseStagingView, main);
+ addField(useStagingView);
+
Group formattingGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
formattingGroup.setText(UIText.CommittingPreferencePage_formatting);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultDialog.java
index a042c8099a..b0190f2716 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultDialog.java
@@ -56,18 +56,12 @@ class PushResultDialog extends TitleAreaDialog {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- PlatformUI.getWorkbench().getDisplay().asyncExec(
- new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- PushResultDialog dialog = new PushResultDialog(
- shell, repository, result, sourceString, modal);
- dialog.showConfigureButton(showConfigureButton);
- dialog.open();
- }
- });
+ Shell shell = PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell();
+ PushResultDialog dialog = new PushResultDialog(shell,
+ repository, result, sourceString, modal);
+ dialog.showConfigureButton(showConfigureButton);
+ dialog.open();
}
});
}
@@ -105,8 +99,9 @@ class PushResultDialog extends TitleAreaDialog {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- Dialog dlg = SimpleConfigurePushDialog.getDialog(PlatformUI
- .getWorkbench().getDisplay().getActiveShell(),
+ Dialog dlg = SimpleConfigurePushDialog.getDialog(
+ PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell(),
localDb);
dlg.open();
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
index eafa1ce9f8..ae62d9c404 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
@@ -2,6 +2,7 @@
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Roger C. Soares <rogersoares@intelinet.com.br>
* Copyright (C) 2013, Robin Stocker <robin@nibor.org>
+ * Copyright (C) 2016, Daniel Megert <daniel_megert@ch.ibm.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -52,7 +53,6 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.EditableSharedDocumentAdapter.ISharedDocumentAdapterListener;
import org.eclipse.team.internal.ui.synchronize.LocalResourceSaveableComparison;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
@@ -658,8 +658,8 @@ public class GitCompareFileRevisionEditorInput extends SaveableCompareEditorInpu
private ISaveablesLifecycleListener getSaveablesLifecycleListener(
IWorkbenchPart part) {
- ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener) Utils
- .getAdapter(part, ISaveablesLifecycleListener.class);
+ ISaveablesLifecycleListener listener = AdapterUtils.adapt(part,
+ ISaveablesLifecycleListener.class);
if (listener == null)
listener = CommonUtils.getService(part.getSite(), ISaveablesLifecycleListener.class);
return listener;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 82cc3f04e3..0fbb21b44e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -73,9 +73,9 @@ import org.eclipse.egit.ui.internal.commands.shared.ContinueRebaseCommand;
import org.eclipse.egit.ui.internal.commands.shared.SkipRebaseCommand;
import org.eclipse.egit.ui.internal.commit.CommitHelper;
import org.eclipse.egit.ui.internal.commit.CommitJob;
+import org.eclipse.egit.ui.internal.commit.CommitJob.PushMode;
import org.eclipse.egit.ui.internal.commit.CommitMessageHistory;
import org.eclipse.egit.ui.internal.commit.CommitProposalProcessor;
-import org.eclipse.egit.ui.internal.commit.CommitJob.PushMode;
import org.eclipse.egit.ui.internal.components.ToggleableWarningLabel;
import org.eclipse.egit.ui.internal.decorators.IProblemDecoratable;
import org.eclipse.egit.ui.internal.decorators.ProblemLabelDecorator;
@@ -129,6 +129,8 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.CheckoutCommand;
import org.eclipse.jgit.api.Git;
@@ -137,8 +139,6 @@ import org.eclipse.jgit.api.RmCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
-import org.eclipse.jgit.annotations.NonNull;
-import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.events.ListenerHandle;
import org.eclipse.jgit.events.RefsChangedEvent;
import org.eclipse.jgit.events.RefsChangedListener;
@@ -158,6 +158,8 @@ import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
@@ -237,7 +239,7 @@ public class StagingView extends ViewPart implements IShowInSource {
private Form form;
- private SashForm horizontalSashForm;
+ private SashForm mainSashForm;
private Section stagedSection;
@@ -610,7 +612,7 @@ public class StagingView extends ViewPart implements IShowInSource {
}
@Override
- public void createPartControl(Composite parent) {
+ public void createPartControl(final Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(parent);
toolkit = new FormToolkit(parent.getDisplay());
@@ -629,21 +631,44 @@ public class StagingView extends ViewPart implements IShowInSource {
});
form = toolkit.createForm(parent);
+ parent.addControlListener(new ControlListener() {
+
+ private int[] defaultWeights = { 1, 1 };
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ org.eclipse.swt.graphics.Rectangle b = parent.getBounds();
+ int oldOrientation = mainSashForm.getOrientation();
+ if ((oldOrientation == SWT.HORIZONTAL)
+ && (b.height > b.width)) {
+ mainSashForm.setOrientation(SWT.VERTICAL);
+ mainSashForm.setWeights(defaultWeights);
+ } else if ((oldOrientation == SWT.VERTICAL)
+ && (b.height <= b.width)) {
+ mainSashForm.setOrientation(SWT.HORIZONTAL);
+ mainSashForm.setWeights(defaultWeights);
+ }
+ }
+ @Override
+ public void controlMoved(ControlEvent e) {
+ // ignore
+ }
+ });
form.setImage(getImage(UIIcons.REPOSITORY));
form.setText(UIText.StagingView_NoSelectionTitle);
GridDataFactory.fillDefaults().grab(true, true).applyTo(form);
toolkit.decorateFormHeading(form);
GridLayoutFactory.swtDefaults().applyTo(form.getBody());
- horizontalSashForm = new SashForm(form.getBody(), SWT.NONE);
- saveSashFormWeightsOnDisposal(horizontalSashForm,
+ mainSashForm = new SashForm(form.getBody(), SWT.HORIZONTAL);
+ saveSashFormWeightsOnDisposal(mainSashForm,
HORIZONTAL_SASH_FORM_WEIGHT);
- toolkit.adapt(horizontalSashForm, true, true);
+ toolkit.adapt(mainSashForm, true, true);
GridDataFactory.fillDefaults().grab(true, true)
- .applyTo(horizontalSashForm);
+ .applyTo(mainSashForm);
- stagingSashForm = new SashForm(horizontalSashForm,
+ stagingSashForm = new SashForm(mainSashForm,
getStagingFormOrientation());
saveSashFormWeightsOnDisposal(stagingSashForm,
STAGING_SASH_FORM_WEIGHT);
@@ -710,7 +735,7 @@ public class StagingView extends ViewPart implements IShowInSource {
enableAutoExpand(unstagedViewer);
addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
- Composite rebaseAndCommitComposite = toolkit.createComposite(horizontalSashForm);
+ Composite rebaseAndCommitComposite = toolkit.createComposite(mainSashForm);
rebaseAndCommitComposite.setLayout(GridLayoutFactory.fillDefaults().create());
rebaseSection = toolkit.createSection(rebaseAndCommitComposite,
@@ -1230,7 +1255,7 @@ public class StagingView extends ViewPart implements IShowInSource {
}
private void restoreSashFormWeights() {
- restoreSashFormWeights(horizontalSashForm,
+ restoreSashFormWeights(mainSashForm,
HORIZONTAL_SASH_FORM_WEIGHT);
restoreSashFormWeights(stagingSashForm,
STAGING_SASH_FORM_WEIGHT);
@@ -3277,7 +3302,13 @@ public class StagingView extends ViewPart implements IShowInSource {
@Override
public void setFocus() {
- unstagedViewer.getControl().setFocus();
+ Tree tree = unstagedViewer.getTree();
+ if (tree.getItemCount() > 0) {
+ tree.setSelection(tree.getItems());
+ unstagedViewer.getControl().setFocus();
+ return;
+ }
+ commitMessageText.setFocus();
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 7028633803..bc1cff5d08 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -767,7 +767,7 @@ CommitAction_amendNotPossible=Commit/amend not possible. Possible causes\:\n\n-
CommitAction_cannotCommit=Cannot commit now
CommitAction_CommittingChanges=Committing changes
CommitAction_CommittingFailed=Committing failed
-CommitAction_errorComputingDiffs=Error occurred computing diffs
+CommitAction_errorComputingDiffs=Error occurred computing Git commit diffs
CommitAction_errorRetrievingCommit=Error occurred retrieving last commit
CommitAction_noFilesToCommit=No files to commit
CommitAction_repositoryState=Repository state: {0}
@@ -1032,6 +1032,7 @@ CommittingPreferencePage_WarnBlock_Errors=Errors
CommittingPreferencePage_WarnBlock_WarningsAndErrors=Warnings and errors
CommittingPreferencePage_BlockCommit=Block commit button
CommittingPreferencePage_BlockCommitCombo=Block if there are:
+CommittingPreferencePage_AlwaysUseStagingView=Use Staging View to commit instead of Commit Dialog
DateFormatPreferencePage_title=Date Format
DateFormatPreferencePage_formatChooser_label=&Format:

Back to the top