@Test public void testRenameList() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.ensureUpToDate(false); final LocalChangeList list = changeListManager.addChangeList("test", null); changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)}); final String newName = "renamed"; myScheme.doTest( new Runnable() { @Override public void run() { changeListManager.editName(list.getName(), newName); checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager); } }); checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager); changeListManager.ensureUpToDate(false); checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager); }
@Test public void testSetActive() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.ensureUpToDate(false); final LocalChangeList list = changeListManager.addChangeList("test", null); final LocalChangeList target = changeListManager.addChangeList("target", null); changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)}); myScheme.doTest( new Runnable() { @Override public void run() { changeListManager.setDefaultChangeList(target); assert changeListManager.getDefaultChangeList().getName().equals(target.getName()); } }); assert changeListManager.getDefaultChangeList().getName().equals(target.getName()); changeListManager.ensureUpToDate(false); assert changeListManager.getDefaultChangeList().getName().equals(target.getName()); }
@Test public void testEditComment() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.ensureUpToDate(false); final String listName = "test"; final LocalChangeList list = changeListManager.addChangeList(listName, null); changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)}); final String finalText = "final text"; myScheme.doTest( new Runnable() { public void run() { final String intermediate = "intermediate text"; changeListManager.editComment(list.getName(), intermediate); assert changeListManager.findChangeList(listName) != null; LocalChangeList list = changeListManager.findChangeList(listName); assert intermediate.equals(list.getComment()); changeListManager.editComment(list.getName(), finalText); list = changeListManager.findChangeList(listName); assert finalText.equals(list.getComment()); } }); LocalChangeList changedList = changeListManager.findChangeList(listName); assert finalText.equals(changedList.getComment()); changeListManager.ensureUpToDate(false); changedList = changeListManager.findChangeList(listName); assert finalText.equals(changedList.getComment()); }
@Test public void testDoubleMove() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.ensureUpToDate(false); final LocalChangeList list = changeListManager.addChangeList("test", null); final LocalChangeList target = changeListManager.addChangeList("target", null); final LocalChangeList target2 = changeListManager.addChangeList("target2", null); changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)}); myScheme.doTest( new Runnable() { public void run() { changeListManager.moveChangesTo( target, new Change[] {changeListManager.getChange(file)}); checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager); changeListManager.moveChangesTo( target2, new Change[] {changeListManager.getChange(file)}); checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager); } }); checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager); changeListManager.ensureUpToDate(false); checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager); }
@Test public void testRemove() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final VirtualFile fileB = createFileInCommand("b.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.ensureUpToDate(false); final LocalChangeList list = changeListManager.addChangeList("test", null); changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)}); myScheme.doTest( new Runnable() { public void run() { changeListManager.removeChangeList(list.getName()); assert changeListManager.findChangeList(list.getName()) == null; checkFilesAreInList( new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager); } }); assert changeListManager.findChangeList(list.getName()) == null; checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager); changeListManager.ensureUpToDate(false); assert changeListManager.findChangeList(list.getName()) == null; checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager); }
@Test public void testComplex() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final VirtualFile fileB = createFileInCommand("b.txt", "old content"); final VirtualFile fileC = createFileInCommand("c.txt", "old content"); final VirtualFile fileD = createFileInCommand("d.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final LocalChangeList list = changeListManager.addChangeList("test", null); final LocalChangeList toBeDeletedList = changeListManager.addChangeList("toBeDeletedList", null); changeListManager.moveChangesTo( list, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)}); changeListManager.moveChangesTo( toBeDeletedList, new Change[] {changeListManager.getChange(fileC), changeListManager.getChange(fileD)}); changeListManager.ensureUpToDate(false); final String targetName = "target"; final String finalName = "final list name"; myScheme.doTest( new Runnable() { @Override public void run() { final LocalChangeList target = changeListManager.addChangeList(targetName, null); changeListManager.moveChangesTo( target, new Change[] { changeListManager.getChange(file), changeListManager.getChange(fileB) }); checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager); changeListManager.editName(targetName, finalName); checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager); changeListManager.removeChangeList(toBeDeletedList.getName()); checkFilesAreInList( new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager); changeListManager.moveChangesTo( LocalChangeList.createEmptyChangeList(myProject, finalName), new Change[] {changeListManager.getChange(fileC)}); checkFilesAreInList( new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager); checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager); } }); checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager); checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager); changeListManager.ensureUpToDate(false); checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager); checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager); }
@Test public void testDeletion() throws Exception { final File f = new File(myClientRoot, "f.txt"); f.createNewFile(); final VirtualFile vf = myLFS.refreshAndFindFileByIoFile(f); myChangeListManager.ensureUpToDate(false); ((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles().contains(vf); FileUtil.delete(f); myWorkingCopyDir.refresh(false, true); myChangeListManager.ensureUpToDate(false); ((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles().isEmpty(); }
@Test public void testSwitchedFileAndFolder() throws Exception { final String branchUrl = prepareBranchesStructure(); final SubTree tree = new SubTree(myWorkingCopyDir); verify(runSvn("switch", branchUrl + "/root/source/s1.txt", tree.myS1File.getPath())); verify(runSvn("switch", branchUrl + "/root/target", tree.myTargetDir.getPath())); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty(); changeListManager.ensureUpToDate(false); final Runnable check = new Runnable() { @Override public void run() { Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File)); Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File)); Assert.assertEquals( FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir)); Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir)); Assert.assertEquals( FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1))); } }; myScheme.doTest(check); changeListManager.ensureUpToDate(false); check.run(); editFileInCommand(myProject, tree.myS1File, "1234543534543 3543 "); VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty(); changeListManager.ensureUpToDate(false); final Runnable check2 = new Runnable() { @Override public void run() { Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File)); Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File)); Assert.assertEquals( FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir)); Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir)); Assert.assertEquals( FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1))); } }; myScheme.doTest(check2); changeListManager.ensureUpToDate(false); check2.run(); }
@Test public void testAddListBySvn() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); final VirtualFile file = createFileInCommand("a.txt", "old content"); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final String targetName = "target"; // not parralel, just test of correct detection runSvn("changelist", targetName, file.getPath()); VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty(); changeListManager.ensureUpToDate(false); checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager); }
public void doTest(final Runnable runnable) { final TimeoutWaiter waiter = new TimeoutWaiter(); final DuringUpdateTest test = new DuringUpdateTest(waiter, runnable); myChangeProvider.setTest(test); waiter.setControlled(test); myDirtyScopeManager.markEverythingDirty(); myClManager.ensureUpToDate(false); waiter.startTimeout(); if (test.getException() != null) { test.getException().printStackTrace(); } assert test.get() : (test.getException() == null ? null : test.getException().getMessage()); }
@Test public void testGeneration() throws Exception { for (int i = 0; i < 100; i++) { final File f = new File(myClientRoot, "f" + i + ".txt"); f.createNewFile(); } myWorkingCopyDir.refresh(false, true); myChangeListManager.ensureUpToDate(false); final List<VirtualFile> unversionedFiles = ((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles(); final Pattern pattern = Pattern.compile("f([0-9])+\\.txt"); int cnt = 0; for (VirtualFile unversionedFile : unversionedFiles) { if (VfsUtil.isAncestor(myWorkingCopyDir, unversionedFile, true)) { ++cnt; Assert.assertTrue(pattern.matcher(unversionedFile.getName()).matches()); } } Assert.assertEquals(100, cnt); }
@Before public void setUp() throws Exception { System.setProperty("svnkit.wc.17", "false"); UIUtil.invokeAndWaitIfNeeded( new Runnable() { @Override public void run() { try { final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); myTempDirFixture = fixtureFactory.createTempDirTestFixture(); myTempDirFixture.setUp(); final File svnRoot = new File(myTempDirFixture.getTempDirPath(), "svnroot"); svnRoot.mkdir(); File pluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea")); if (!pluginRoot.isDirectory()) { // try standalone mode Class aClass = SvnTestCase.class; String rootPath = PathManager.getResourceRoot( aClass, "/" + aClass.getName().replace('.', '/') + ".class"); pluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile(); } myClientBinaryPath = new File(pluginRoot, "testData/svn/bin"); ZipUtil.extract(new File(pluginRoot, "testData/svn/newrepo.zip"), svnRoot, null); myWcRoot = new File(myTempDirFixture.getTempDirPath(), "wcroot"); myWcRoot.mkdir(); myRepoUrl = "file:///" + FileUtil.toSystemIndependentName(svnRoot.getPath()); initProject(myWcRoot); activateVCS(SvnVcs17.VCS_NAME); verify(runSvn("co", myRepoUrl, ".")); myGate = new MockChangeListManagerGate(ChangeListManager.getInstance(myProject)); myRefreshCopiesStub = new AtomicSectionsAware() { @Override public void enter() {} @Override public void exit() {} @Override public boolean shouldExitAsap() { return false; } @Override public void checkShouldExit() throws ProcessCanceledException {} }; final SvnVcs17 vcs = SvnVcs17.getInstance(myProject); ((StartupManagerImpl) StartupManager.getInstance(myProject)) .runPostStartupActivities(); // vcs.postStartup(); ((SvnFileUrlMappingImpl17) vcs.getSvnFileUrlMapping()).realRefresh(); } catch (Exception e) { throw new RuntimeException(e); } } }); // there should be kind-a waiting for after change list manager finds all changes and runs inner // refresh of copies in the above method ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty(); changeListManager.ensureUpToDate(false); }