From 34adfcf080bba2638e09865fa10c7fb417856fd4 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 7 Feb 2013 15:59:54 +0400 Subject: [PATCH] IDEA-100629 Subversion: external copy is not detected (not shown in Subversion working copies) --- .../idea/svn/NestedCopiesBuilder.java | 8 +- .../idea/svn/SvnAuthenticationNotifier.java | 2 +- .../idea/svn/SvnCopiesRefreshManager.java | 100 +++++------------- .../idea/svn/SvnFileUrlMappingImpl.java | 36 +++---- .../src/org/jetbrains/idea/svn/SvnUtil.java | 4 - .../src/org/jetbrains/idea/svn/SvnVcs.java | 70 ++++++------ .../idea/svn/actions/ShareProjectAction.java | 2 +- .../idea/svn/dialogs/CopiesPanel.java | 2 +- .../org/jetbrains/idea/SvnTestCase.java | 60 ++++++++--- .../idea/svn/SvnCommittedViewTest.java | 14 +-- .../svn/SvnExternalCommitNoticedTest.java | 2 +- .../jetbrains/idea/svn/SvnExternalTests.java | 82 ++++++++++---- .../idea/svn16/SvnCommittedViewTest.java | 14 +-- .../svn16/SvnExternalCommitNoticedTest.java | 2 +- .../idea/svn16/SvnExternalTests.java | 6 +- 15 files changed, 211 insertions(+), 193 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java index ee6631df94b6..9fa68eab8765 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java @@ -78,7 +78,7 @@ public class NestedCopiesBuilder implements StatusReceiver { final File ioFile = new File(vf.getPath()); final RootUrlInfo info = myMapping.getWcRootForFilePath(ioFile); if (info != null && FileUtil.filesEqual(ioFile, info.getIoFile()) && ! info.getAbsoluteUrlAsUrl().equals(url)) { - SvnVcs.getInstance(myProject).invokeRefreshSvnRoots(true); + SvnVcs.getInstance(myProject).invokeRefreshSvnRoots(); } } @@ -87,7 +87,7 @@ public class NestedCopiesBuilder implements StatusReceiver { private SVNURL myUrl; private WorkingCopyFormat myFormat; private final NestedCopyType myType; - private final SVNURL myRootURL; + private SVNURL myRootURL; MyPointInfo(@NotNull final VirtualFile file, final SVNURL url, @@ -149,6 +149,10 @@ public class NestedCopiesBuilder implements StatusReceiver { public int hashCode() { return key(myFile).hashCode(); } + + public void setRootURL(final SVNURL value) { + myRootURL = value; + } } public Set getSet() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index cdf92851c5ce..8a94f0076acf 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -146,7 +146,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl outdatedRequests = new LinkedList(); final Collection keys = getAllCurrentKeys(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnCopiesRefreshManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnCopiesRefreshManager.java index 1040abdfd16b..248e930edc6f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnCopiesRefreshManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnCopiesRefreshManager.java @@ -16,95 +16,43 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.RequestsMerger; import com.intellij.util.Consumer; import com.intellij.util.concurrency.Semaphore; public class SvnCopiesRefreshManager { - private final CopiesRefresh myCopiesRefresh; + private final RequestsMerger myRequestsMerger; + private final Semaphore mySemaphore; + private Runnable myMappingCallback; - public SvnCopiesRefreshManager(final Project project, final SvnFileUrlMappingImpl mapping) { - myCopiesRefresh = new MyVeryRefresh(); - - final Runnable refresher = new MyRefresher(mapping); - - final RequestsMerger requestsMerger = new RequestsMerger(refresher, new Consumer() { + public SvnCopiesRefreshManager(final SvnFileUrlMappingImpl mapping) { + mySemaphore = new Semaphore(); + // svn mappings refresh inside also uses asynchronous pass -> we need to pass callback that will ping our "single-threaded" executor here + myMappingCallback = new Runnable() { + @Override + public void run() { + mySemaphore.up(); + } + }; + myRequestsMerger = new RequestsMerger(new Runnable() { + @Override + public void run() { + mySemaphore.down(); + mapping.realRefresh(myMappingCallback); + mySemaphore.waitFor(); + } + }, new Consumer() { public void consume(final Runnable runnable) { ApplicationManager.getApplication().executeOnPooledThread(runnable); } }); - ((MyVeryRefresh) myCopiesRefresh).setRequestMerger(requestsMerger); } - public CopiesRefresh getCopiesRefresh() { - return myCopiesRefresh; + public void asynchRequest() { + myRequestsMerger.request(); } - private class MyVeryRefresh implements CopiesRefresh { - private static final long ourQueryInterval = 1000; - private RequestsMerger myRequestMerger; - private final ProgressManager myPm; - - private MyVeryRefresh() { - myPm = ProgressManager.getInstance(); - } - - public void setRequestMerger(RequestsMerger requestMerger) { - myRequestMerger = requestMerger; - } - - public void ensureInit() { - synchRequest(myPm.getProgressIndicator(), true); - } - - public void asynchRequest() { - myRequestMerger.request(); - } - - public void synchRequest() { - synchRequest(myPm.getProgressIndicator(), false); - } - - private void synchRequest(final ProgressIndicator pi, final boolean isOnlyInit) { - final Semaphore semaphore = new Semaphore(); - final Runnable waiter = new Runnable() { - public void run() { - semaphore.up(); - } - }; - semaphore.down(); - if (isOnlyInit) { - myRequestMerger.ensureInitialization(waiter); - } else { - myRequestMerger.waitRefresh(waiter); - } - while (true) { - if (semaphore.waitFor(ourQueryInterval)) break; - if (pi != null) { - pi.checkCanceled(); - } - } - } - } - - private static class MyRefresher implements Runnable { - private final SvnFileUrlMappingImpl myMapping; - - private MyRefresher(final SvnFileUrlMappingImpl mapping) { - myMapping = mapping; - } - - public void run() { - try { - myMapping.realRefresh(); - } - catch (ProcessCanceledException e) { - // - } - } + public void waitRefresh(final Runnable runnable) { + myRequestsMerger.waitRefresh(runnable); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java index c6f6f67ea645..257fcff426bf 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java @@ -221,7 +221,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState } } - public void realRefresh() { + public void realRefresh(final Runnable callback) { final SvnVcs vcs = SvnVcs.getInstance(myProject); final VirtualFile[] roots = myHelper.executeDefended(myProject); @@ -232,7 +232,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState } }); // do not send additional request for nested copies when in init state - copiesDetector.detectCopyRoots(roots, init()); + copiesDetector.detectCopyRoots(roots, init(), callback); } private class CopiesApplier { @@ -292,7 +292,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState myRepositoryRoots = new RepositoryRoots(myVcs); } - public void detectCopyRoots(final VirtualFile[] roots, final boolean clearState) { + public void detectCopyRoots(final VirtualFile[] roots, final boolean clearState, Runnable callback) { final Getter cancelGetter = new Getter() { public Boolean get() { return myVcs.getProject().isDisposed(); @@ -300,6 +300,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState }; for (final VirtualFile vcsRoot : roots) { + // go into nested = false => only find a working copys below passed roots, but not nested final List foundRoots = ForNestedRootChecker.getAllNestedWorkingCopies(vcsRoot, myVcs, false, cancelGetter); if (foundRoots.isEmpty()) { myLonelyRoots.add(vcsRoot); @@ -317,10 +318,10 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState } } - addNestedRoots(clearState); + addNestedRoots(clearState, callback); } - private void addNestedRoots(final boolean clearState) { + private void addNestedRoots(final boolean clearState, final Runnable callback) { final List basicVfRoots = ObjectsConvertor.convert(myTopRoots, new Convertor() { public VirtualFile convert(final RootUrlInfo real) { return real.getVirtualFile(); @@ -343,7 +344,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState final File infoFile = new File(info.getFile().getPath()); boolean copyFound = false; for (RootUrlInfo topRoot : myTopRoots) { - if (topRoot.getIoFile().equals(infoFile)) { + if (FileUtil.filesEqual(topRoot.getIoFile(), infoFile)) { topRoot.setType(info.getType()); copyFound = true; break; @@ -357,6 +358,9 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState if (svnStatus.getURL() == null) continue; info.setUrl(svnStatus.getURL()); info.setFormat(WorkingCopyFormat.getInstance(svnStatus.getWorkingCopyFormat())); + if (svnStatus.getRepositoryRootURL() != null) { + info.setRootURL(svnStatus.getRepositoryRootURL()); + } } catch (Exception e) { continue; @@ -365,7 +369,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState for (RootUrlInfo topRoot : myTopRoots) { if (VfsUtil.isAncestor(topRoot.getVirtualFile(), info.getFile(), true)) { SVNURL repoRoot = info.getRootURL(); - repoRoot = repoRoot == null ? myRepositoryRoots.ask(info.getUrl(), true) : repoRoot; + repoRoot = repoRoot == null ? myRepositoryRoots.ask(info.getUrl(), info.getFile()) : repoRoot; if (repoRoot != null) { final RootUrlInfo rootInfo = new RootUrlInfo(repoRoot, info.getUrl(), info.getFormat(), info.getFile(), topRoot.getRoot()); rootInfo.setType(info.getType()); @@ -380,6 +384,8 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState myTopRoots.addAll(nestedRoots); myApplier.apply(myVcs, myTopRoots, myLonelyRoots); + + callback.run(); } }, InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED, null, new Consumer() { public void consume(VcsDirtyScopeManager vcsDirtyScopeManager) { @@ -404,22 +410,16 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState myRoots.add(url); } - public SVNURL ask(final SVNURL url, boolean allowRemote) { + public SVNURL ask(final SVNURL url, VirtualFile file) { for (SVNURL root : myRoots) { if (root.equals(SVNURLUtil.getCommonURLAncestor(root, url))) { return root; } } - final SVNURL newUrl; - try { - newUrl = SvnUtil.getRepositoryRoot(myVcs, url, allowRemote); - if (newUrl != null) { - myRoots.add(newUrl); - return newUrl; - } - } - catch (SVNException e) { - // + final SVNURL newUrl = SvnUtil.getRepositoryRoot(myVcs, new File(file.getPath())); + if (newUrl != null) { + myRoots.add(newUrl); + return newUrl; } return null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java index f407b175e79a..ee25402d8ff0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java @@ -422,10 +422,6 @@ public class SvnUtil { @Nullable 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/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index 9b46857d5833..7f269ba82d23 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -29,7 +29,6 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; @@ -263,7 +262,7 @@ public class SvnVcs extends AbstractVcs { myVcsListener = new VcsListener() { @Override public void directoryMappingChanged() { - invokeRefreshSvnRoots(true); + invokeRefreshSvnRoots(); } }; } @@ -289,7 +288,7 @@ public class SvnVcs extends AbstractVcs { public void postStartup() { if (myProject.isDefault()) return; - myCopiesRefreshManager = new SvnCopiesRefreshManager(myProject, (SvnFileUrlMappingImpl) getSvnFileUrlMapping()); + myCopiesRefreshManager = new SvnCopiesRefreshManager((SvnFileUrlMappingImpl) getSvnFileUrlMapping()); if (! myConfiguration.isCleanupRun()) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override @@ -299,54 +298,49 @@ public class SvnVcs extends AbstractVcs { } }, ModalityState.NON_MODAL, myProject.getDisposed()); } else { - invokeRefreshSvnRoots(true); + invokeRefreshSvnRoots(); } myWorkingCopiesContent.activate(); } private void cleanup17copies() { - new CleanupWorker(new VirtualFile[]{}, myProject, "action.Subversion.cleanup.progress.title") { - @Override - protected void chanceToFillRoots() { - myCopiesRefreshManager.getCopiesRefresh().synchRequest(); - final List infos = getAllWcInfos(); - final LocalFileSystem lfs = LocalFileSystem.getInstance(); - final List roots = new ArrayList(infos.size()); - for (WCInfo info : infos) { - if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat())) { - final VirtualFile file = lfs.refreshAndFindFileByIoFile(new File(info.getPath())); - if (file == null) { - LOG.info("Wasn't able to find virtual file for wc root: " + info.getPath()); - } else { - roots.add(file); + final Runnable callCleanupWorker = new Runnable() { + public void run() { + new CleanupWorker(new VirtualFile[]{}, myProject, "action.Subversion.cleanup.progress.title") { + @Override + protected void chanceToFillRoots() { + final List infos = getAllWcInfos(); + final LocalFileSystem lfs = LocalFileSystem.getInstance(); + final List roots = new ArrayList(infos.size()); + for (WCInfo info : infos) { + if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat())) { + final VirtualFile file = lfs.refreshAndFindFileByIoFile(new File(info.getPath())); + if (file == null) { + LOG.info("Wasn't able to find virtual file for wc root: " + info.getPath()); + } else { + roots.add(file); + } + } } + myRoots = roots.toArray(new VirtualFile[roots.size()]); } - } - myRoots = roots.toArray(new VirtualFile[roots.size()]); + }.execute(); } - }.execute(); + }; + + myCopiesRefreshManager.waitRefresh(new Runnable() { + @Override + public void run() { + callCleanupWorker.run(); + } + }); } - public void invokeRefreshSvnRoots(final boolean asynchronous) { + public void invokeRefreshSvnRoots() { REFRESH_LOG.debug("refresh: ", new Throwable()); if (myCopiesRefreshManager != null) { - if (asynchronous) { - myCopiesRefreshManager.getCopiesRefresh().asynchRequest(); - } - else { - if (ApplicationManager.getApplication().isDispatchThread()) { - ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { - @Override - public void run() { - myCopiesRefreshManager.getCopiesRefresh().synchRequest(); - } - }, SvnBundle.message("refreshing.working.copies.roots.progress.text"), true, myProject); - } - else { - myCopiesRefreshManager.getCopiesRefresh().synchRequest(); - } - } + myCopiesRefreshManager.asynchRequest(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java index fa0305fa5e09..975a1641b0c5 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java @@ -171,7 +171,7 @@ public class ShareProjectAction extends BasicAction { } catch (SVNException e) { error[0] = e; } finally { - activeVcs.invokeRefreshSvnRoots(true); + activeVcs.invokeRefreshSvnRoots(); SvnWorkingCopyFormatHolder.setPresetFormat(null); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index cdb712b0b1e1..d66cb6f0ae54 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -154,7 +154,7 @@ public class CopiesPanel { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { if (myRefreshLabel.isEnabled()) { - myVcs.invokeRefreshSvnRoots(true); + myVcs.invokeRefreshSvnRoots(); myRefreshLabel.setEnabled(false); } } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/SvnTestCase.java b/plugins/svn4idea/testSource/org/jetbrains/idea/SvnTestCase.java index 7fcff59c5537..da46b816336c 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/SvnTestCase.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/SvnTestCase.java @@ -38,6 +38,7 @@ import com.intellij.openapi.vcs.VcsShowConfirmationOption; import com.intellij.openapi.vcs.changes.*; import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; import com.intellij.openapi.vcs.update.CommonUpdateProjectAction; +import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.newvfs.BulkFileListener; @@ -49,6 +50,7 @@ import com.intellij.testFramework.vcs.AbstractJunitVcsTestCase; import com.intellij.testFramework.vcs.MockChangeListManagerGate; import com.intellij.testFramework.vcs.MockChangelistBuilder; import com.intellij.testFramework.vcs.TestClientRunner; +import com.intellij.util.concurrency.Semaphore; import com.intellij.util.io.ZipUtil; import com.intellij.util.ui.UIUtil; import junit.framework.Assert; @@ -85,6 +87,7 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase { private File myRepoRoot; private File myWcRoot; private ChangeListManagerGate myGate; + protected String myAnotherRepoUrl; protected SvnTestCase(@NotNull String testDataDir) { PlatformTestCase.initPlatformLangPrefix(); @@ -164,10 +167,8 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase { myGate = new MockChangeListManagerGate(ChangeListManager.getInstance(myProject)); - final SvnVcs vcs = SvnVcs.getInstance(myProject); ((StartupManagerImpl) StartupManager.getInstance(myProject)).runPostStartupActivities(); - ((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(); - + refreshSvnMappingsSynchronously(); } catch (Exception e) { throw new RuntimeException(e); @@ -183,6 +184,19 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase { } } + protected void refreshSvnMappingsSynchronously() { + final SvnVcs vcs = SvnVcs.getInstance(myProject); + final Semaphore semaphore = new Semaphore(); + semaphore.down(); + ((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(new Runnable() { + @Override + public void run() { + semaphore.up(); + } + }); + semaphore.waitFor(); + } + @Override protected void projectCreated() { if (myUseNativeAcceleration) { @@ -325,22 +339,29 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase { verify(runSvn("copy", "-q", "-m", "coppy", mainUrl, branchUrl)); clManager.forceGoInTestMode(); - vcs.invokeRefreshSvnRoots(false); - clManager.ensureUpToDate(false); - clManager.ensureUpToDate(false); + refreshSvnMappingsSynchronously(); + //clManager.ensureUpToDate(false); + //clManager.ensureUpToDate(false); return branchUrl; } public void prepareExternal() throws Exception { - prepareExternal(true, true); + prepareExternal(true, true, false); } - public void prepareExternal(final boolean commitExternalDefinition, final boolean updateExternal) throws Exception { + public void prepareExternal(final boolean commitExternalDefinition, final boolean updateExternal, + final boolean anotherRepository) throws Exception { final ChangeListManagerImpl clManager = (ChangeListManagerImpl)ChangeListManager.getInstance(myProject); final SvnVcs vcs = SvnVcs.getInstance(myProject); final String mainUrl = myRepoUrl + "/root/source"; - final String externalURL = myRepoUrl + "/root/target"; + final String externalURL; + if (anotherRepository) { + createAnotherRepo(); + externalURL = myAnotherRepoUrl + "/root/target"; + } else { + externalURL = myRepoUrl + "/root/target"; + } final SubTree subTree = new SubTree(myWorkingCopyDir); checkin(); @@ -374,9 +395,24 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase { // start change list manager again clManager.forceGoInTestMode(); - vcs.invokeRefreshSvnRoots(false); - clManager.ensureUpToDate(false); - clManager.ensureUpToDate(false); + refreshSvnMappingsSynchronously(); + //clManager.ensureUpToDate(false); + //clManager.ensureUpToDate(false); + } + + private void createAnotherRepo() throws Exception { + final File repo = FileUtil.createTempDirectory("anotherRepo", ""); + FileUtil.delete(repo); + FileUtil.copyDir(myRepoRoot, repo); + myAnotherRepoUrl = (SystemInfo.isWindows ? "file:///" : "file://") + FileUtil.toSystemIndependentName(repo.getPath()); + final File tmpWc = FileUtil.createTempDirectory("hhh", ""); + verify(runSvn("co", myAnotherRepoUrl, tmpWc.getPath())); + final VirtualFile tmpWcVf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tmpWc); + Assert.assertNotNull(tmpWcVf); + final SubTree tree = new SubTree(tmpWcVf); + verify(myRunner.runClient("svn", null, tmpWc, "add", "root")); + verify(myRunner.runClient("svn", null, tmpWc, "ci", "-m", "fff")); + FileUtil.delete(tmpWc); } protected static void imitUpdate(final Project project) { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCommittedViewTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCommittedViewTest.java index 2b430f9805a9..c863f8e7e369 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCommittedViewTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCommittedViewTest.java @@ -57,7 +57,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -89,7 +89,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -121,7 +121,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -150,7 +150,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -182,7 +182,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -207,7 +207,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -237,7 +237,7 @@ public class SvnCommittedViewTest extends Svn17TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalCommitNoticedTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalCommitNoticedTest.java index 03460c7aeadc..91f30c9452d3 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalCommitNoticedTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalCommitNoticedTest.java @@ -134,7 +134,7 @@ public class SvnExternalCommitNoticedTest extends Svn17TestCase { final String branchUrl = prepareBranchesStructure(); final SubTree tree = new SubTree(myWorkingCopyDir); - myVcs.invokeRefreshSvnRoots(false); + myVcs.invokeRefreshSvnRoots(); clManager.ensureUpToDate(false); clManager.ensureUpToDate(false); SvnFileUrlMapping workingCopies = myVcs.getSvnFileUrlMapping(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalTests.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalTests.java index ad8099b75dcc..443dc9502696 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalTests.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnExternalTests.java @@ -64,12 +64,25 @@ public class SvnExternalTests extends Svn17TestCase { @Test public void testExternalCopyIsDetected() throws Exception { prepareExternal(); + externalCopyIsDetectedImpl(); + } + @Test + public void testExternalCopyIsDetectedAnotherRepo() throws Exception { + prepareExternal(true, true, true); + externalCopyIsDetectedImpl(); + } + + private void externalCopyIsDetectedImpl() { final SvnFileUrlMapping workingCopies = myVcs.getSvnFileUrlMapping(); final List infos = workingCopies.getAllWcInfos(); Assert.assertEquals(2, infos.size()); final Set expectedUrls = new HashSet(); - expectedUrls.add(StringUtil.toLowerCase(myExternalURL)); + if (myAnotherRepoUrl != null) { + expectedUrls.add(StringUtil.toLowerCase(myAnotherRepoUrl + "/root/target")); + } else { + expectedUrls.add(StringUtil.toLowerCase(myExternalURL)); + } expectedUrls.add(StringUtil.toLowerCase(myMainUrl)); for (RootUrlInfo info : infos) { @@ -100,9 +113,9 @@ public class SvnExternalTests extends Svn17TestCase { // start change list manager again clManager.forceGoInTestMode(); - myVcs.invokeRefreshSvnRoots(false); - clManager.ensureUpToDate(false); - clManager.ensureUpToDate(false); + refreshSvnMappingsSynchronously(); + //clManager.ensureUpToDate(false); + //clManager.ensureUpToDate(false); } @Test @@ -128,6 +141,16 @@ public class SvnExternalTests extends Svn17TestCase { @Test public void testSimpleExternalsStatus() throws Exception { prepareExternal(); + simpleExternalStatusImpl(); + } + + @Test + public void testSimpleExternalsAnotherStatus() throws Exception { + prepareExternal(true, true, true); + simpleExternalStatusImpl(); + } + + private void simpleExternalStatusImpl() { final File sourceFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "s1.txt"); final File externalFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "external" + File.separator + "t12.txt"); @@ -159,7 +182,17 @@ public class SvnExternalTests extends Svn17TestCase { @Test public void testUpdatedCreatedExternalFromIDEA() throws Exception { - prepareExternal(false, false); + prepareExternal(false, false, false); + updatedCreatedExternalFromIDEAImpl(); + } + + @Test + public void testUpdatedCreatedExternalFromIDEAAnother() throws Exception { + prepareExternal(false, false, true); + updatedCreatedExternalFromIDEAImpl(); + } + + private void updatedCreatedExternalFromIDEAImpl() { final File sourceDir = new File(myWorkingCopyDir.getPath(), "source"); ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings( Arrays.asList(new VcsDirectoryMapping(FileUtil.toSystemIndependentName(sourceDir.getPath()), myVcs.getName()))); @@ -172,8 +205,17 @@ public class SvnExternalTests extends Svn17TestCase { @Test public void testUncommittedExternalStatus() throws Exception { - prepareExternal(false, true); + prepareExternal(false, true, false); + uncommittedExternalStatusImpl(); + } + @Test + public void testUncommittedExternalStatusAnother() throws Exception { + prepareExternal(false, true, true); + uncommittedExternalStatusImpl(); + } + + private void uncommittedExternalStatusImpl() { final File sourceDir = new File(myWorkingCopyDir.getPath(), "source"); final File externalFile = new File(sourceDir, "external/t11.txt"); final VirtualFile externalVf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(externalFile); @@ -190,25 +232,23 @@ public class SvnExternalTests extends Svn17TestCase { @Test public void testUncommittedExternalCopyIsDetected() throws Exception { - prepareExternal(false, false); + prepareExternal(false, false, false); + uncommittedExternalCopyIsDetectedImpl(); + } + + @Test + public void testUncommittedExternalCopyIsDetectedAnother() throws Exception { + prepareExternal(false, false, true); + uncommittedExternalCopyIsDetectedImpl(); + } + + private void uncommittedExternalCopyIsDetectedImpl() { final File sourceDir = new File(myWorkingCopyDir.getPath(), "source"); ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings( Arrays.asList(new VcsDirectoryMapping(FileUtil.toSystemIndependentName(sourceDir.getPath()), myVcs.getName()))); imitUpdate(myProject); - myVcs.invokeRefreshSvnRoots(false); - clManager.ensureUpToDate(false); - clManager.ensureUpToDate(false); + refreshSvnMappingsSynchronously(); - final SvnFileUrlMapping workingCopies = myVcs.getSvnFileUrlMapping(); - final List infos = workingCopies.getAllWcInfos(); - Assert.assertEquals(2, infos.size()); - final Set expectedUrls = new HashSet(); - expectedUrls.add(StringUtil.toLowerCase(myExternalURL)); - expectedUrls.add(StringUtil.toLowerCase(myMainUrl)); - - for (RootUrlInfo info : infos) { - expectedUrls.remove(StringUtil.toLowerCase(info.getAbsoluteUrl())); - } - Assert.assertTrue(expectedUrls.isEmpty()); + externalCopyIsDetectedImpl(); } } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java index d7b2752d4735..26ee4206ffcc 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java @@ -59,7 +59,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -91,7 +91,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -120,7 +120,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -149,7 +149,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -181,7 +181,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -206,7 +206,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -236,7 +236,7 @@ public class SvnCommittedViewTest extends Svn16TestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); - vcs.invokeRefreshSvnRoots(false); + vcs.invokeRefreshSvnRoots(); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalCommitNoticedTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalCommitNoticedTest.java index 2384914e5098..22953c7b7f21 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalCommitNoticedTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalCommitNoticedTest.java @@ -138,7 +138,7 @@ public class SvnExternalCommitNoticedTest extends Svn17TestCase { final String branchUrl = prepareBranchesStructure(); final SubTree tree = new SubTree(myWorkingCopyDir); - myVcs.invokeRefreshSvnRoots(false); + myVcs.invokeRefreshSvnRoots(); clManager.ensureUpToDate(false); clManager.ensureUpToDate(false); SvnFileUrlMapping workingCopies = myVcs.getSvnFileUrlMapping(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalTests.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalTests.java index 06a8c1fe3459..94d8ee2d6255 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalTests.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnExternalTests.java @@ -97,9 +97,9 @@ public class SvnExternalTests extends Svn17TestCase { // start change list manager again clManager.forceGoInTestMode(); - myVcs.invokeRefreshSvnRoots(false); - clManager.ensureUpToDate(false); - clManager.ensureUpToDate(false); + refreshSvnMappingsSynchronously(); + //clManager.ensureUpToDate(false); + //clManager.ensureUpToDate(false); } @Test