From bc6c95f79b94d7430375f4894518198c8675d7ea Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 13 Dec 2012 17:14:45 +0400 Subject: [PATCH] IDEA-97459 Subversion: working copies refresh should not ask for authentication --- .../idea/svn/NestedCopiesBuilder.java | 20 ++++++++++++++----- .../jetbrains/idea/svn/StatusReceiver.java | 2 +- .../idea/svn/SvnChangeProviderContext.java | 2 +- .../idea/svn/SvnFileUrlMappingImpl.java | 7 ++++--- .../idea/svn/SvnRecursiveStatusWalker.java | 2 +- .../src/org/jetbrains/idea/svn/SvnUtil.java | 8 ++++++-- .../history/SvnEditCommitMessageAction.java | 2 +- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java index b811bf888a50..ee6631df94b6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java @@ -42,7 +42,7 @@ public class NestedCopiesBuilder implements StatusReceiver { public void process(final FilePath path, final SVNStatus status) throws SVNException { if ((path.getVirtualFile() != null) && SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)) { - final MyPointInfo info = new MyPointInfo(path.getVirtualFile(), null, WorkingCopyFormat.UNKNOWN, NestedCopyType.external); + final MyPointInfo info = new MyPointInfo(path.getVirtualFile(), null, WorkingCopyFormat.UNKNOWN, NestedCopyType.external, null); mySet.add(info); return; } @@ -57,7 +57,7 @@ public class NestedCopiesBuilder implements StatusReceiver { return; } final MyPointInfo info = new MyPointInfo(path.getVirtualFile(), status.getURL(), - WorkingCopyFormat.getInstance(status.getWorkingCopyFormat()), type); + WorkingCopyFormat.getInstance(status.getWorkingCopyFormat()), type, status.getRepositoryRootURL()); mySet.add(info); } @@ -68,8 +68,8 @@ public class NestedCopiesBuilder implements StatusReceiver { } @Override - public void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format) { - final MyPointInfo info = new MyPointInfo(file, url, format, NestedCopyType.inner); + public void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL) { + final MyPointInfo info = new MyPointInfo(file, url, format, NestedCopyType.inner, rootURL); mySet.add(info); } @@ -87,18 +87,28 @@ public class NestedCopiesBuilder implements StatusReceiver { private SVNURL myUrl; private WorkingCopyFormat myFormat; private final NestedCopyType myType; + private final SVNURL myRootURL; - MyPointInfo(@NotNull final VirtualFile file, final SVNURL url, final WorkingCopyFormat format, final NestedCopyType type) { + MyPointInfo(@NotNull final VirtualFile file, + final SVNURL url, + final WorkingCopyFormat format, + final NestedCopyType type, + SVNURL rootURL) { myFile = file; myUrl = url; myFormat = format; myType = type; + myRootURL = rootURL; } public void setUrl(SVNURL url) { myUrl = url; } + public SVNURL getRootURL() { + return myRootURL; + } + public void setFormat(WorkingCopyFormat format) { myFormat = format; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java index d89fff56efe5..3008585b90b8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java @@ -27,6 +27,6 @@ public interface StatusReceiver extends EventListener { void process(final FilePath path, final SVNStatus status) throws SVNException; void processIgnored(final VirtualFile vFile); void processUnversioned(final VirtualFile vFile); - void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format); + void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL); void bewareRoot(VirtualFile vf, SVNURL url, WorkingCopyFormat copyFormat); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java index ab0202090eb8..64db261e01b4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java @@ -70,7 +70,7 @@ class SvnChangeProviderContext implements StatusReceiver { } @Override - public void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format) { + public void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL) { } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java index fba32993e815..3f8536af7474 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java @@ -366,7 +366,8 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState } for (RootUrlInfo topRoot : myTopRoots) { if (VfsUtil.isAncestor(topRoot.getVirtualFile(), info.getFile(), true)) { - final SVNURL repoRoot = myRepositoryRoots.ask(info.getUrl()); + SVNURL repoRoot = info.getRootURL(); + repoRoot = repoRoot == null ? myRepositoryRoots.ask(info.getUrl(), true) : repoRoot; if (repoRoot != null) { final RootUrlInfo rootInfo = new RootUrlInfo(repoRoot, info.getUrl(), info.getFormat(), info.getFile(), topRoot.getRoot()); rootInfo.setType(info.getType()); @@ -405,7 +406,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState myRoots.add(url); } - public SVNURL ask(final SVNURL url) { + public SVNURL ask(final SVNURL url, boolean allowRemote) { for (SVNURL root : myRoots) { if (root.equals(SVNURLUtil.getCommonURLAncestor(root, url))) { return root; @@ -413,7 +414,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState } final SVNURL newUrl; try { - newUrl = SvnUtil.getRepositoryRoot(myVcs, url); + newUrl = SvnUtil.getRepositoryRoot(myVcs, url, allowRemote); if (newUrl != null) { myRoots.add(newUrl); return newUrl; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java index 61c487ff94c1..f4fdfac1114d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java @@ -250,7 +250,7 @@ public class SvnRecursiveStatusWalker { if (vf != null) { if (myCurrentItem.isIsInnerCopyRoot()) { myReceiver.processCopyRoot(vf, statusInner.getURL(), - WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat())); + WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat()), statusInner.getRepositoryRootURL()); } else { myReceiver.bewareRoot(vf, statusInner.getURL(), WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat())); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java index 2597e63f9bfc..c5f88f7d6760 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java @@ -412,7 +412,7 @@ public class SvnUtil { @Nullable public static SVNURL getRepositoryRoot(final SvnVcs vcs, final String url) { try { - return getRepositoryRoot(vcs, SVNURL.parseURIEncoded(url)); + return getRepositoryRoot(vcs, SVNURL.parseURIEncoded(url), true); } catch (SVNException e) { return null; @@ -420,8 +420,12 @@ public class SvnUtil { } @Nullable - public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url) throws SVNException { + public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url, boolean allowRemote) throws SVNException { final SVNWCClient client = vcs.createWCClient(); + SVNInfo localInfo = client.doInfo(url, SVNRevision.UNDEFINED, SVNRevision.WORKING); + if (localInfo != null && localInfo.getRepositoryRootURL() != null || ! allowRemote) { + return localInfo == null ? null : localInfo.getRepositoryRootURL(); + } SVNInfo info = client.doInfo(url, SVNRevision.UNDEFINED, SVNRevision.HEAD); return (info == null) ? null : info.getRepositoryRootURL(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnEditCommitMessageAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnEditCommitMessageAction.java index d67e29b598a0..5ca1150869ae 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnEditCommitMessageAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnEditCommitMessageAction.java @@ -137,7 +137,7 @@ public class SvnEditCommitMessageAction extends AnAction { final String url = myLocation.getURL(); final SVNURL root; try { - root = SvnUtil.getRepositoryRoot(myVcs, SVNURL.parseURIEncoded(url)); + root = SvnUtil.getRepositoryRoot(myVcs, SVNURL.parseURIEncoded(url), true); if (root == null) { myException = new VcsException("Can not determine repository root for URL: " + url); return;