Search in sources :

Example 31 with FilePath

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

the class VcsDirtyScopeManagerImpl method calculateInvalidated.

@NotNull
private VcsInvalidated calculateInvalidated(@NotNull DirtBuilder dirt) {
    MultiMap<AbstractVcs, FilePath> files = dirt.getFilesForVcs();
    MultiMap<AbstractVcs, FilePath> dirs = dirt.getDirsForVcs();
    if (dirt.isEverythingDirty()) {
        dirs.putAllValues(getEverythingDirtyRoots());
    }
    Set<AbstractVcs> keys = ContainerUtil.union(files.keySet(), dirs.keySet());
    Map<AbstractVcs, VcsDirtyScopeImpl> scopes = ContainerUtil.newHashMap();
    for (AbstractVcs key : keys) {
        VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(key, myProject);
        scopes.put(key, scope);
        scope.addDirtyData(dirs.get(key), files.get(key));
    }
    return new VcsInvalidated(new ArrayList<>(scopes.values()), dirt.isEverythingDirty());
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with FilePath

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

the class VcsDirtyScopeManagerImpl method getEverythingDirtyRoots.

@NotNull
private MultiMap<AbstractVcs, FilePath> getEverythingDirtyRoots() {
    MultiMap<AbstractVcs, FilePath> dirtyRoots = MultiMap.createSet();
    dirtyRoots.putAllValues(groupByVcs(toFilePaths(DefaultVcsRootPolicy.getInstance(myProject).getDirtyRoots())));
    List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings();
    for (VcsDirectoryMapping mapping : mappings) {
        if (!mapping.isDefaultMapping() && mapping.getVcs() != null) {
            AbstractVcs vcs = myVcsManager.findVcsByName(mapping.getVcs());
            if (vcs != null) {
                dirtyRoots.putValue(vcs, VcsUtil.getFilePath(mapping.getDirectory(), true));
            }
        }
    }
    return dirtyRoots;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 33 with FilePath

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

the class DescindingFilesFilter method filterDescindingFiles.

@NotNull
public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
    final List<FilePath> result = new LinkedList<>();
    ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
    Arrays.sort(roots, FilePathComparator.getInstance());
    final Map<VcsKey, List<FilePath>> chains = new HashMap<>();
    for (FilePath root : roots) {
        final AbstractVcs vcs = manager.getVcsFor(root);
        if (vcs == null)
            continue;
        if (vcs.allowsNestedRoots()) {
            // just put into result: nested roots are allowed
            result.add(root);
            continue;
        }
        //if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
        final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
        if (chain == null) {
            final LinkedList<FilePath> newList = new LinkedList<>();
            newList.add(root);
            chains.put(vcs.getKeyInstanceMethod(), newList);
        } else {
            boolean failed = false;
            for (FilePath chainedPath : chain) {
                if (VfsUtilCore.isAncestor(chainedPath.getIOFile(), root.getIOFile(), false)) {
                    // do not take this root
                    failed = true;
                    break;
                }
            }
            if (!failed) {
                chain.add(root);
            }
        }
    }
    for (List<FilePath> filePaths : chains.values()) {
        result.addAll(filePaths);
    }
    return result.toArray(new FilePath[result.size()]);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsKey(com.intellij.openapi.vcs.VcsKey) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 34 with FilePath

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

the class TabbedShowHistoryAction method isEnabled.

protected boolean isEnabled(@NotNull VcsContext context) {
    boolean result = false;
    Project project = context.getProject();
    if (project != null) {
        Pair<FilePath, VirtualFile> pair = getPathAndParentFile(context);
        if (pair.first != null && pair.second != null) {
            result = isEnabled(project, pair.first, pair.second);
        }
    }
    return result;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project)

Example 35 with FilePath

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

the class ChangesPreprocess method preprocessChangesRemoveDeletedForDuplicateMoved.

public static List<Change> preprocessChangesRemoveDeletedForDuplicateMoved(List<Change> list) {
    final List<Change> result = new ArrayList<>();
    final Map<FilePath, Change> map = new HashMap<>();
    for (Change change : list) {
        if (change.getBeforeRevision() == null) {
            result.add(change);
        } else {
            final FilePath beforePath = ChangesUtil.getBeforePath(change);
            final Change existing = map.get(beforePath);
            if (existing == null) {
                map.put(beforePath, change);
                continue;
            }
            if (change.getAfterRevision() == null && existing.getAfterRevision() == null)
                continue;
            if (change.getAfterRevision() != null && existing.getAfterRevision() != null) {
                LOG.error("Incorrect changes list: " + list);
            }
            if (existing.getAfterRevision() != null && change.getAfterRevision() == null) {
                // skip delete change
                continue;
            }
            if (change.getAfterRevision() != null && existing.getAfterRevision() == null) {
                // skip delete change
                map.put(beforePath, change);
            }
        }
    }
    result.addAll(map.values());
    return result;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

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