Search in sources :

Example 6 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnDiffProvider method createFileContent.

@NotNull
@Override
public ContentRevision createFileContent(@NotNull VcsRevisionNumber revisionNumber, @NotNull VirtualFile selectedFile) {
    FilePath filePath = VcsUtil.getFilePath(selectedFile);
    SVNRevision svnRevision = ((SvnRevisionNumber) revisionNumber).getRevision();
    if (!SVNRevision.HEAD.equals(svnRevision) && revisionNumber.equals(getCurrentRevision(selectedFile))) {
        return SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision);
    }
    // not clear why we need it, with remote check..
    Status svnStatus = getFileStatus(VfsUtilCore.virtualToIoFile(selectedFile), false);
    return svnStatus != null && svnRevision.equals(svnStatus.getRevision()) ? SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision) : SvnContentRevision.createRemote(myVcs, filePath, svnRevision);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Status(org.jetbrains.idea.svn.status.Status) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnChangeProvider method createFileProvider.

@NotNull
private static ISVNStatusFileProvider createFileProvider(@NotNull Map<String, SvnScopeZipper.MyDirNonRecursive> nonRecursiveMap) {
    final Map<String, Map<String, File>> result = ContainerUtil.newHashMap();
    for (SvnScopeZipper.MyDirNonRecursive item : nonRecursiveMap.values()) {
        File file = item.getDir().getIOFile();
        Map<String, File> fileMap = ContainerUtil.getOrCreate(result, file.getAbsolutePath(), NAME_TO_FILE_MAP_FACTORY);
        for (FilePath path : item.getChildrenList()) {
            fileMap.put(path.getName(), path.getIOFile());
        }
        // see http://issues.tmatesoft.com/issue/SVNKIT-567 for details
        if (file.getParentFile() != null) {
            Map<String, File> parentMap = ContainerUtil.getOrCreate(result, file.getParentFile().getAbsolutePath(), NAME_TO_FILE_MAP_FACTORY);
            parentMap.put(file.getName(), file);
        }
    }
    return parent -> result.get(parent.getAbsolutePath());
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) FileStatus(com.intellij.openapi.vcs.FileStatus) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) java.util(java.util) EventDispatcher(com.intellij.util.EventDispatcher) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Document(com.intellij.openapi.editor.Document) com.intellij.openapi.vcs.changes(com.intellij.openapi.vcs.changes) NotNullFactory(com.intellij.openapi.util.NotNullFactory) Computable(com.intellij.openapi.util.Computable) SvnExceptionWrapper(org.jetbrains.idea.svn.commandLine.SvnExceptionWrapper) ContainerUtil(com.intellij.util.containers.ContainerUtil) CleanupWorker(org.jetbrains.idea.svn.actions.CleanupWorker) Comparing(com.intellij.openapi.util.Comparing) VcsContextFactory(com.intellij.openapi.vcs.actions.VcsContextFactory) Logger(com.intellij.openapi.diagnostic.Logger) VcsException(com.intellij.openapi.vcs.VcsException) FilePath(com.intellij.openapi.vcs.FilePath) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) ProgressManager(com.intellij.openapi.progress.ProgressManager) VcsUtil(com.intellij.vcsUtil.VcsUtil) SVNException(org.tmatesoft.svn.core.SVNException) StringUtil(com.intellij.openapi.util.text.StringUtil) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Status(org.jetbrains.idea.svn.status.Status) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) StatusType(org.jetbrains.idea.svn.status.StatusType) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Depth(org.jetbrains.idea.svn.api.Depth) ISVNStatusFileProvider(org.tmatesoft.svn.core.wc.ISVNStatusFileProvider) SVNURL(org.tmatesoft.svn.core.SVNURL) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ObjectUtils(com.intellij.util.ObjectUtils) NotNull(org.jetbrains.annotations.NotNull) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnChangeProvider method processCopiedFile.

private void processCopiedFile(@NotNull SvnChangedFile copiedFile, @NotNull SvnChangeProviderContext context, @Nullable VcsDirtyScope dirtyScope) throws SVNException {
    boolean foundRename = false;
    final Status copiedStatus = copiedFile.getStatus();
    final String copyFromURL = ObjectUtils.assertNotNull(copiedFile.getCopyFromURL());
    final Set<SvnChangedFile> deletedToDelete = new HashSet<>();
    for (SvnChangedFile deletedFile : context.getDeletedFiles()) {
        final Status deletedStatus = deletedFile.getStatus();
        if (deletedStatus.getURL() != null && Comparing.equal(copyFromURL, deletedStatus.getURL().toString())) {
            final String clName = SvnUtil.getChangelistName(copiedFile.getStatus());
            applyMovedChange(context, copiedFile.getFilePath(), dirtyScope, deletedToDelete, deletedFile, copiedStatus, clName);
            for (SvnChangedFile deletedChild : context.getDeletedFiles()) {
                final Status childStatus = deletedChild.getStatus();
                final SVNURL childUrl = childStatus.getURL();
                if (childUrl == null) {
                    continue;
                }
                final String childURL = childUrl.toDecodedString();
                if (StringUtil.startsWithConcatenation(childURL, copyFromURL, "/")) {
                    String relativePath = childURL.substring(copyFromURL.length());
                    File newPath = new File(copiedFile.getFilePath().getIOFile(), relativePath);
                    FilePath newFilePath = myFactory.createFilePathOn(newPath);
                    if (!context.isDeleted(newFilePath)) {
                        applyMovedChange(context, newFilePath, dirtyScope, deletedToDelete, deletedChild, context.getTreeConflictStatus(newPath), clName);
                    }
                }
            }
            foundRename = true;
            break;
        }
    }
    final List<SvnChangedFile> deletedFiles = context.getDeletedFiles();
    for (SvnChangedFile file : deletedToDelete) {
        deletedFiles.remove(file);
    }
    // by building a relative url
    if (!foundRename && copiedStatus.getURL() != null) {
        File wcPath = myVcs.getSvnFileUrlMapping().getLocalPath(copyFromURL);
        if (wcPath != null) {
            Status status;
            try {
                status = myVcs.getFactory(wcPath).createStatusClient().doStatus(wcPath, false);
            } catch (SvnBindException ex) {
                LOG.info(ex);
                status = null;
            }
            if (status != null && status.is(StatusType.STATUS_DELETED)) {
                final FilePath filePath = myFactory.createFilePathOnDeleted(wcPath, false);
                final SvnContentRevision beforeRevision = SvnContentRevision.createBaseRevision(myVcs, filePath, status.getRevision());
                final ContentRevision afterRevision = CurrentContentRevision.create(copiedFile.getFilePath());
                context.getBuilder().processChangeInList(context.createMovedChange(beforeRevision, afterRevision, copiedStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey());
                foundRename = true;
            }
        }
    }
    if (!foundRename) {
        // for debug
        LOG.info("Rename not found for " + copiedFile.getFilePath().getPresentableUrl());
        context.processStatus(copiedFile.getFilePath(), copiedStatus);
    }
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) Status(org.jetbrains.idea.svn.status.Status) FilePath(com.intellij.openapi.vcs.FilePath) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 9 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnChangeProviderContext method loadEntriesFile.

/**
   * Ensures that the contents of the 'entries' file is cached in the VFS, so that the VFS will send
   * correct events when the 'entries' file is changed externally (to be received by SvnEntriesFileListener)
   *
   * @param filePath the path of a changed file.
   */
private void loadEntriesFile(@NotNull FilePath filePath) {
    final FilePath parentPath = filePath.getParentPath();
    if (parentPath == null) {
        return;
    }
    refreshDotSvnAndEntries(parentPath);
    if (filePath.isDirectory()) {
        refreshDotSvnAndEntries(filePath);
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath)

Example 10 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnChangeProviderContext method createPropertyRevision.

@Nullable
private ContentRevision createPropertyRevision(@NotNull Change change, @NotNull File file, boolean isBeforeRevision) throws SVNException {
    FilePath path = ChangesUtil.getFilePath(change);
    ContentRevision contentRevision = isBeforeRevision ? change.getBeforeRevision() : change.getAfterRevision();
    SVNRevision revision = isBeforeRevision ? SVNRevision.BASE : SVNRevision.WORKING;
    return new SimplePropertyRevision(getPropertyList(myVcs, file, revision), path, getRevisionNumber(contentRevision));
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SimplePropertyRevision(org.jetbrains.idea.svn.history.SimplePropertyRevision) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)167 VirtualFile (com.intellij.openapi.vfs.VirtualFile)68 NotNull (org.jetbrains.annotations.NotNull)43 VcsException (com.intellij.openapi.vcs.VcsException)34 File (java.io.File)30 Change (com.intellij.openapi.vcs.changes.Change)26 Nullable (org.jetbrains.annotations.Nullable)22 Project (com.intellij.openapi.project.Project)20 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)15 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)13 FileStatus (com.intellij.openapi.vcs.FileStatus)10 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)8 GitRepository (git4idea.repo.GitRepository)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Test (org.junit.Test)6 StringUtil (com.intellij.openapi.util.text.StringUtil)5 Logger (com.intellij.openapi.diagnostic.Logger)4