SVN 1.7: old -> new: IDEA-53015 Ask for subversion credentials right away!

This commit is contained in:
irengrig
2012-01-25 12:30:36 +04:00
parent f42eb55e86
commit e767b8dfe0
4 changed files with 33 additions and 7 deletions
@@ -18,7 +18,9 @@ package org.jetbrains.idea.svn17;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
@@ -95,7 +97,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
final Ref<Boolean> resultRef = new Ref<Boolean>();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
final Runnable checker = new Runnable() {
@Override
public void run() {
try {
@@ -106,11 +108,20 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
if (result) {
onStateChangedToSuccess(obj);
}
} finally {
}
finally {
myVerificationInProgress = false;
}
}
});
};
final ApplicationEx application = (ApplicationEx)ApplicationManager.getApplication();
// also do not show auth if thread does not have progress indicator
if (application.holdsReadLock() || application.isDispatchThread() || ! ProgressManager.getInstance().hasProgressIndicator()) {
application.executeOnPooledThread(checker);
} else {
checker.run();
return resultRef.get();
}
return false;
}
@@ -164,6 +175,15 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
return super.ensureNotify(obj);
}
@Override
protected boolean onFirstNotification(AuthenticationRequest obj) {
if (ProgressManager.getInstance().hasProgressIndicator()) {
return ask(obj, null);
} else {
return false;
}
}
@NotNull
@Override
public SVNURL getKey(final AuthenticationRequest obj) {
@@ -265,7 +265,7 @@ public class SvnConfiguration17 implements PersistentStateComponent<Element> {
myAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory()));
getInteractiveManager(svnVcs);
// to init
myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider));
myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, RUNTIME_AUTH_CACHE));
myAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
}
return myAuthManager;
@@ -27,6 +27,7 @@ import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider;
import org.tmatesoft.svn.core.auth.SVNAuthentication;
import org.tmatesoft.svn.core.auth.SVNUserNameAuthentication;
import org.tmatesoft.svn.core.internal.wc.ISVNAuthenticationStorage;
import java.util.HashSet;
import java.util.Set;
@@ -39,9 +40,12 @@ public class SvnAuthenticationProvider implements ISVNAuthenticationProvider {
private final Project myProject;
private final SvnAuthenticationNotifier myAuthenticationNotifier;
private final ISVNAuthenticationProvider mySvnInteractiveAuthenticationProvider;
private final ISVNAuthenticationStorage myAuthenticationStorage;
private static final Set<Thread> ourForceInteractive = new HashSet<Thread>();
public SvnAuthenticationProvider(final SvnVcs17 svnVcs, final ISVNAuthenticationProvider provider) {
public SvnAuthenticationProvider(final SvnVcs17 svnVcs, final ISVNAuthenticationProvider provider,
final ISVNAuthenticationStorage authenticationStorage) {
myAuthenticationStorage = authenticationStorage;
myProject = svnVcs.getProject();
myAuthenticationNotifier = svnVcs.getAuthNotifier();
mySvnInteractiveAuthenticationProvider = provider;
@@ -68,7 +72,9 @@ public class SvnAuthenticationProvider implements ISVNAuthenticationProvider {
// outside-project url
return mySvnInteractiveAuthenticationProvider.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored);
} else {
myAuthenticationNotifier.ensureNotify(obj);
if (myAuthenticationNotifier.ensureNotify(obj)) {
return (SVNAuthentication) myAuthenticationStorage.getData(kind, realm);
}
}
return null;
}
@@ -80,7 +80,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
myAuthenticationManager = new SvnAuthenticationManager(myProject, configFile);
myInteractiveProvider = new SvnTestInteractiveAuthentication(myAuthenticationManager);
myAuthenticationManager.setAuthenticationProvider(new SvnAuthenticationProvider(vcs, myInteractiveProvider));
myAuthenticationManager.setAuthenticationProvider(new SvnAuthenticationProvider(vcs, myInteractiveProvider, SvnConfiguration17.RUNTIME_AUTH_CACHE));
myAuthenticationManager.setRuntimeStorage(SvnConfiguration17.RUNTIME_AUTH_CACHE);
myTestInteraction = new TestInteraction();