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());
}
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;
}
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()]);
}
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;
}
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;
}
Aggregations