Search in sources :

Example 6 with AbstractVcs

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

the class RemoteRevisionsNumbersCache method directoryMappingChanged.

public void directoryMappingChanged() {
    // copy myData under lock
    HashSet<String> keys;
    synchronized (myLock) {
        keys = new HashSet<>(myData.keySet());
    }
    // collect new vcs for scheduled files
    final Map<String, Pair<VirtualFile, AbstractVcs>> vFiles = new HashMap<>();
    for (String key : keys) {
        final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(key));
        final AbstractVcs newVcs = (vf == null) ? null : myVcsManager.getVcsFor(vf);
        vFiles.put(key, vf == null ? Pair.create((VirtualFile) null, (AbstractVcs) null) : Pair.create(vf, newVcs));
    }
    synchronized (myLock) {
        keys = new HashSet<>(myData.keySet());
        for (String key : keys) {
            final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
            final VcsRoot storedVcsRoot = value.getFirst();
            final Pair<VirtualFile, AbstractVcs> pair = vFiles.get(key);
            if (pair == null) {
                // already added with new mappings
                continue;
            }
            final VirtualFile vf = pair.getFirst();
            final AbstractVcs newVcs = pair.getSecond();
            if (newVcs == null) {
                myData.remove(key);
                getQueue(storedVcsRoot).forceRemove(key);
            } else {
                final VirtualFile newRoot = myVcsManager.getVcsRootFor(vf);
                final VcsRoot newVcsRoot = new VcsRoot(newVcs, newRoot);
                if (!storedVcsRoot.equals(newVcsRoot)) {
                    switchVcs(storedVcsRoot, newVcsRoot, key);
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Pair(com.intellij.openapi.util.Pair)

Example 7 with AbstractVcs

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

the class RemoteRevisionsNumbersCache method plus.

public void plus(final Pair<String, AbstractVcs> pair) {
    // does not support
    if (pair.getSecond().getDiffProvider() == null)
        return;
    final String key = pair.getFirst();
    final AbstractVcs newVcs = pair.getSecond();
    final VirtualFile root = getRootForPath(key);
    if (root == null)
        return;
    final VcsRoot vcsRoot = new VcsRoot(newVcs, root);
    synchronized (myLock) {
        final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
        if (value == null) {
            final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
            myData.put(key, Pair.create(vcsRoot, NOT_LOADED));
            queue.addRequest(key);
        } else if (!value.getFirst().equals(vcsRoot)) {
            switchVcs(value.getFirst(), vcsRoot, key);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 8 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs 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 9 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs 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 10 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs 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)

Aggregations

AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 NotNull (org.jetbrains.annotations.NotNull)12 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)7 VcsRoot (com.intellij.openapi.vcs.VcsRoot)7 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)6 Nullable (org.jetbrains.annotations.Nullable)5 Module (com.intellij.openapi.module.Module)3 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)3 VcsKey (com.intellij.openapi.vcs.VcsKey)3 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)3 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)3 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 Date (java.util.Date)3 Pair (com.intellij.openapi.util.Pair)2 VcsException (com.intellij.openapi.vcs.VcsException)2 DiffProvider (com.intellij.openapi.vcs.diff.DiffProvider)2 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)2 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)2