Search in sources :

Example 1 with SvnTreeConflictResolver

use of org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver in project intellij-community by JetBrains.

the class SvnResolveTreeAcceptVariantsTest method testMineFull.

@Test
public void testMineFull() throws Exception {
    int cnt = 0;
    myWorkingCopyDir = createDirInCommand(myWorkingCopyDir, "test--");
    myTheirs = createDirInCommand(myTheirs, "theirs--");
    //final TreeConflictData.Data data = TreeConflictData.FileToFile.MINE_EDIT_THEIRS_MOVE;
    for (final TreeConflictData.Data data : TreeConflictData.ourAll) {
        if (myTraceClient) {
            System.out.println("========= TEST " + getTestName(data) + " =========");
        }
        ((ChangeListManagerImpl) myChangeListManager).stopEveryThingIfInTestMode();
        myWorkingCopyDir = createDirInCommand(myWorkingCopyDir.getParent(), "test" + cnt);
        myTheirs = createDirInCommand(myTheirs.getParent(), "theirs" + cnt);
        mySvnClientRunner.checkout(myRepoUrl, myTheirs);
        mySvnClientRunner.checkout(myRepoUrl, myWorkingCopyDir);
        sleep(200);
        ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings(Collections.singletonList(new VcsDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName())));
        createSubTree(data);
        myTheirs.refresh(false, true);
        final ConflictCreator creator = new ConflictCreator(myProject, myTheirs, myWorkingCopyDir, data, mySvnClientRunner);
        creator.create();
        sleep(200);
        ((ChangeListManagerImpl) myChangeListManager).forceGoInTestMode();
        myDirtyScopeManager.markEverythingDirty();
        myChangeListManager.ensureUpToDate(false);
        myDirtyScopeManager.markEverythingDirty();
        myChangeListManager.ensureUpToDate(false);
        final String conflictFile = data.getConflictFile();
        final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile);
        final FilePath filePath = VcsUtil.getFilePath(conflictIoFile);
        final Change change = myChangeListManager.getChange(filePath);
        Assert.assertNotNull(change);
        Assert.assertTrue(change instanceof ConflictedSvnChange);
        final SvnRevisionNumber committedRevision = change.getBeforeRevision() != null ? (SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber() : null;
        //SvnRevisionNumber committedRevision = new SvnRevisionNumber(SVNRevision.create(cnt * 2 + 1));
        final SvnTreeConflictResolver resolver = new SvnTreeConflictResolver(myVcs, filePath, null);
        resolver.resolveSelectMineFull();
        myTheirs.refresh(false, true);
        myWorkingCopyDir.refresh(false, true);
        checkStatusesAfterMineFullResolve(data, conflictIoFile);
        checkFileContents(data, conflictIoFile);
        ++cnt;
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) ChangeListManagerImpl(com.intellij.openapi.vcs.changes.ChangeListManagerImpl) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) Change(com.intellij.openapi.vcs.changes.Change) SvnTreeConflictResolver(org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) Test(org.junit.Test)

Example 2 with SvnTreeConflictResolver

use of org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver in project intellij-community by JetBrains.

the class SvnResolveTreeAcceptVariantsTest method testTheirsFull.

@Test
public void testTheirsFull() throws Exception {
    int cnt = 0;
    myWorkingCopyDir = createDirInCommand(myWorkingCopyDir, "test--");
    myTheirs = createDirInCommand(myTheirs, "theirs--");
    //final TreeConflictData.Data data = TreeConflictData.FileToFile.MINE_MOVE_THEIRS_ADD;
    for (final TreeConflictData.Data data : TreeConflictData.ourAll) {
        if (myTraceClient) {
            System.out.println("========= TEST " + getTestName(data) + " =========");
        }
        myWorkingCopyDir = createDirInCommand(myWorkingCopyDir.getParent(), "test" + cnt);
        myTheirs = createDirInCommand(myTheirs.getParent(), "theirs" + cnt);
        mySvnClientRunner.checkout(myRepoUrl, myTheirs);
        mySvnClientRunner.checkout(myRepoUrl, myWorkingCopyDir);
        createSubTree(data);
        final ConflictCreator creator = new ConflictCreator(myProject, myTheirs, myWorkingCopyDir, data, mySvnClientRunner);
        creator.create();
        myDirtyScopeManager.markEverythingDirty();
        myChangeListManager.ensureUpToDate(false);
        myDirtyScopeManager.markEverythingDirty();
        myChangeListManager.ensureUpToDate(false);
        final String conflictFile = data.getConflictFile();
        final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile);
        final FilePath filePath = VcsUtil.getFilePath(conflictIoFile);
        final Change change = myChangeListManager.getChange(filePath);
        Assert.assertNotNull(change);
        Assert.assertTrue(change instanceof ConflictedSvnChange);
        final SvnRevisionNumber committedRevision = change.getBeforeRevision() != null ? (SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber() : null;
        FilePath beforePath = null;
        if (change.isMoved() || change.isRenamed()) {
            beforePath = change.getBeforeRevision().getFile();
        }
        //SvnRevisionNumber committedRevision = new SvnRevisionNumber(SVNRevision.create(cnt * 2 + 1));
        final SvnTreeConflictResolver resolver = new SvnTreeConflictResolver(myVcs, filePath, beforePath);
        resolver.resolveSelectTheirsFull();
        myTheirs.refresh(false, true);
        myWorkingCopyDir.refresh(false, true);
        VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, file -> {
            final String relative = VfsUtil.getRelativePath(file, myTheirs, File.separatorChar);
            File workingFile = new File(myWorkingCopyDir.getPath(), relative);
            boolean exists = workingFile.exists();
            if (!exists) {
                String[] excluded = data.getExcludeFromToTheirsCheck();
                if (excluded != null && Arrays.asList(excluded).contains(relative)) {
                    return true;
                }
                Assert.assertTrue("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath(), exists);
            }
            final File theirsFile = virtualToIoFile(file);
            Info theirsInfo = myVcs.getInfo(theirsFile);
            Info thisInfo = myVcs.getInfo(workingFile);
            if (theirsInfo != null) {
                Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(), theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber());
                if (!theirsFile.isDirectory()) {
                    try {
                        final String workText = FileUtil.loadFile(workingFile);
                        final String theirsText = FileUtil.loadFile(theirsFile);
                        Assert.assertEquals(theirsText, workText);
                    } catch (IOException e) {
                        Assert.assertTrue(e.getMessage(), false);
                    }
                }
            }
            return true;
        });
        ++cnt;
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Change(com.intellij.openapi.vcs.changes.Change) IOException(java.io.IOException) Info(org.jetbrains.idea.svn.info.Info) SvnTreeConflictResolver(org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) Test(org.junit.Test)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)2 Change (com.intellij.openapi.vcs.changes.Change)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 SvnTreeConflictResolver (org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver)2 Test (org.junit.Test)2 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)1 ChangeListManagerImpl (com.intellij.openapi.vcs.changes.ChangeListManagerImpl)1 IOException (java.io.IOException)1 Info (org.jetbrains.idea.svn.info.Info)1