IDEA-52201 (svn credentials not remembered)
authorirengrig <Irina.Chernushina@jetbrains.com>
Tue, 16 Feb 2010 10:58:12 +0000 (13:58 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Tue, 16 Feb 2010 10:58:12 +0000 (13:58 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBranchConfigurationManager.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java
plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java

index 8c9ac54e81316af875242bd7878a292401e5fbae..822cddff6adabfc268864d1b76da3ed3630994ec 100644 (file)
@@ -549,6 +549,7 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
 
     for(ChangesCacheFile cache: caches) {
       try {
+        if (! cache.getVcs().isVcsBackgroundOperationsAllowed(cache.getRootPath().getVirtualFile())) continue;
         if (!cache.isEmpty()) {
           debug("Loading incoming changes for " + cache.getLocation());
           final List<CommittedChangeList> incomingChanges = cache.loadIncomingChanges();
index 2528b75ccd9349f3cedbc72b27d2bacb2b0049ef..f5e35844976e77bf84496c4bab5bd2453459297d 100644 (file)
@@ -100,6 +100,13 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager {
     }
   }
 
+  public boolean haveStoredCredentials(final String kind, final SVNURL url, final String realm, final SVNErrorMessage errorMessage,
+                                                         final SVNAuthentication previousAuth) {
+    final SVNAuthentication result =
+      myPersistentAuthenticationProviderProxy.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, false);
+    return result != null;
+  }
+
   public ISVNProxyManager getProxyManager(SVNURL url) throws SVNException {
     // this code taken from default manager (changed for system properties reading)
       String host = url.getHost();
index 4e6b3b5431a2bad1ccf903c24b56e14cb92c751e..f35d8c7b888ffd01ab7312d2b988418872f99345 100644 (file)
@@ -128,7 +128,13 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
   public ThreeState isAuthenticatedFor(final VirtualFile vf) {
     final WorkingCopy wcCopy = myRootsToWorkingCopies.getWcRoot(vf);
     if (wcCopy == null) return ThreeState.UNSURE;
-    return getStateFor(wcCopy.getUrl()) ? ThreeState.NO : ThreeState.YES;
+
+    // check there's no cancellation yet
+    final boolean haveCancellation = getStateFor(wcCopy.getUrl());
+    if (! haveCancellation) return ThreeState.NO;
+
+    // check have credentials
+    return passiveValidation(myVcs.getProject(), wcCopy.getUrl()) ? ThreeState.YES : ThreeState.NO;
   }
 
   @NotNull
@@ -196,11 +202,10 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
     LOG.debug(s);
   }
 
-  public static boolean passiveValidation(final Project project, final SVNURL url, final boolean checkWrite,
-                                          final String realm, final String kind) {
+  public static boolean passiveValidation(final Project project, final SVNURL url) {
     final SvnConfiguration configuration = SvnConfiguration.getInstance(project);
     final ISVNAuthenticationManager passiveManager = configuration.getPassiveAuthenticationManager();
-    return validationImpl(project, url, configuration, passiveManager, checkWrite, realm, kind);
+    return validationImpl(project, url, configuration, passiveManager, false, null, null);
   }
 
   public static boolean interactiveValidation(final Project project, final SVNURL url, final String realm, final String kind) {
index 64853c0c76a4540c81132b4fb7fd1b7339b2cda2..2241a6f64125ce4eaf6c111d5fa9c319229b110f 100644 (file)
@@ -157,6 +157,8 @@ public class SvnBranchConfigurationManager implements PersistentStateComponent<S
       if (! vcs.isVcsBackgroundOperationsAllowed(myRoot)) return;
 
       for (String newBranchUrl : next.getBranchUrls()) {
+        // check if cancel had been put 
+        if (! vcs.isVcsBackgroundOperationsAllowed(myRoot)) return;
         if (myAll || (! oldUrls.contains(newBranchUrl))) {
           new NewRootBunch.BranchesLoadRunnable(myProject, myBunch, newBranchUrl, InfoReliability.defaultValues, myRoot, null).run();
         }
index 6d4b81273d3f36c51c71e94c014b9ff2888cbe02..3eb75612cd89e18764867750d8e9d7fd1ff99449 100644 (file)
@@ -223,7 +223,7 @@ public class SvnConfiguration implements ProjectComponent, JDOMExternalizable {
     return myAuthManager;
   }
 
-  public ISVNAuthenticationManager getPassiveAuthenticationManager() {
+  public SvnAuthenticationManager getPassiveAuthenticationManager() {
     if (myPassiveAuthManager == null) {
         myPassiveAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory()));
         myPassiveAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
index e09c352edf172b520889c617a19df64ff211cb18..26c88ef255f0debf844b112d9e0bbf6d001c4933 100644 (file)
  */
 package org.jetbrains.idea.svn.branchConfig;
 
-import com.intellij.lifecycle.PeriodicalTasksCloser;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.ProjectLevelVcsManager;
-import org.jetbrains.idea.svn.SvnVcs;
+import org.jetbrains.idea.svn.SvnConfiguration;
 import org.jetbrains.idea.svn.integrate.SvnBranchItem;
 import org.tmatesoft.svn.core.ISVNDirEntryHandler;
 import org.tmatesoft.svn.core.SVNDirEntry;
 import org.tmatesoft.svn.core.SVNException;
 import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
 import org.tmatesoft.svn.core.wc.SVNLogClient;
 import org.tmatesoft.svn.core.wc.SVNRevision;
 
@@ -40,9 +39,11 @@ public class BranchesLoader {
 
   public static List<SvnBranchItem> loadBranches(final Project project, final String url) throws SVNException {
     final List<SvnBranchItem> result = new LinkedList<SvnBranchItem>();
-    final ProjectLevelVcsManager vcsManager = PeriodicalTasksCloser.safeGetComponent(project, ProjectLevelVcsManager.class);
-    final SvnVcs svnVcs = (SvnVcs) vcsManager.findVcsByName(SvnVcs.VCS_NAME);
-    final SVNLogClient logClient = svnVcs.createLogClient();
+
+    final SvnConfiguration configuration = SvnConfiguration.getInstance(project);
+    final ISVNAuthenticationManager passiveManager = configuration.getPassiveAuthenticationManager();
+
+    final SVNLogClient logClient = new SVNLogClient(passiveManager, configuration.getOptions(project));
     final SVNURL branchesUrl = SVNURL.parseURIEncoded(url);
     logClient.doList(branchesUrl, SVNRevision.UNDEFINED, SVNRevision.HEAD, false, false, new ISVNDirEntryHandler() {
       public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException {