Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-05-24 13:51:54 +02:00
14 changed files with 78 additions and 64 deletions
@@ -52,12 +52,12 @@ public class IdeaTextPatchBuilder {
for (VcsRoot root : byRoots.keySet()) {
final Collection<Change> rootChanges = byRoots.get(root);
if (root.vcs == null || root.vcs.getOutgoingChangesProvider() == null) {
if (root.getVcs() == null || root.getVcs().getOutgoingChangesProvider() == null) {
addConvertChanges(rootChanges, result);
continue;
}
final VcsOutgoingChangesProvider<?> provider = root.vcs.getOutgoingChangesProvider();
final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.path);
final VcsOutgoingChangesProvider<?> provider = root.getVcs().getOutgoingChangesProvider();
final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.getPath());
rootChanges.removeAll(basedOnLocal);
addConvertChanges(rootChanges, result);
@@ -17,18 +17,31 @@
package com.intellij.openapi.vcs;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
/**
* @author yole
*/
public class VcsRoot {
public final AbstractVcs vcs;
public final VirtualFile path;
@Nullable private final AbstractVcs myVcs;
@Nullable private final VirtualFile myPath;
private int hashcode;
public VcsRoot(final AbstractVcs vcs, final VirtualFile path) {
this.vcs = vcs;
this.path = path;
public VcsRoot(@Nullable AbstractVcs vcs, @Nullable VirtualFile path) {
myVcs = vcs;
myPath = path;
}
@Nullable
public AbstractVcs getVcs() {
return myVcs;
}
@Nullable
public VirtualFile getPath() {
return myPath;
}
@Override
@@ -38,26 +51,22 @@ public class VcsRoot {
VcsRoot root = (VcsRoot)o;
if (path != null ? !path.equals(root.path) : root.path != null) return false;
if (vcs != null ? !vcs.getName().equals(root.vcs.getName()) : root.vcs != null) return false;
if (myPath != null ? !myPath.equals(root.myPath) : root.myPath != null) return false;
if (myVcs != null ? !myVcs.equals(root.myVcs) : root.myVcs != null) return false;
return true;
}
@Override
public int hashCode() {
if (hashcode == 0) {
hashcode = vcs != null ? vcs.getName().hashCode() : 0;
hashcode = 31 * hashcode + (path != null ? path.hashCode() : 0);
hashcode = myVcs != null ? myVcs.hashCode() : 0;
hashcode = 31 * hashcode + (myPath != null ? myPath.hashCode() : 0);
}
return hashcode;
}
@Override
public String toString() {
return "VcsRoot{" +
"vcs=" + vcs +
", path=" + path +
'}';
return String.format("VcsRoot{vcs=%s, path=%s}", myVcs, myPath);
}
}
@@ -91,14 +91,14 @@ public class TriggerAdditionOrDeletion {
if (myPreparedDeletion != null) {
for (Map.Entry<VcsRoot, Collection<FilePath>> entry : myPreparedDeletion.entrySet()) {
final VcsRoot vcsRoot = entry.getKey();
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
if (localChangesProvider == null) continue;
final Collection<FilePath> filePaths = entry.getValue();
if (vcsRoot.vcs.fileListenerIsSynchronous()) {
if (vcsRoot.getVcs().fileListenerIsSynchronous()) {
myAffected.addAll(filePaths);
continue;
}
askUserIfNeededDeletion(vcsRoot.vcs, (List<FilePath>)filePaths);
askUserIfNeededDeletion(vcsRoot.getVcs(), (List<FilePath>)filePaths);
myAffected.addAll(filePaths);
localChangesProvider.scheduleMissingFileForDeletion((List<FilePath>)filePaths);
}
@@ -106,14 +106,14 @@ public class TriggerAdditionOrDeletion {
if (myPreparedAddition != null) {
for (Map.Entry<VcsRoot, Collection<FilePath>> entry : myPreparedAddition.entrySet()) {
final VcsRoot vcsRoot = entry.getKey();
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
if (localChangesProvider == null) continue;
final Collection<FilePath> filePaths = entry.getValue();
if (vcsRoot.vcs.fileListenerIsSynchronous()) {
if (vcsRoot.getVcs().fileListenerIsSynchronous()) {
myAffected.addAll(filePaths);
continue;
}
askUserIfNeededAddition(vcsRoot.vcs, (List<FilePath>)filePaths);
askUserIfNeededAddition(vcsRoot.getVcs(), (List<FilePath>)filePaths);
myAffected.addAll(filePaths);
localChangesProvider.scheduleUnversionedFilesForAddition(ObjectsConvertor.fp2vf(filePaths));
}
@@ -128,10 +128,10 @@ public class TriggerAdditionOrDeletion {
final MultiMap<VcsRoot, FilePath> map = sortByVcsRoots.sort(myDeleted);
myPreparedDeletion = new MultiMap<VcsRoot, FilePath>();
for (VcsRoot vcsRoot : map.keySet()) {
if (vcsRoot != null && vcsRoot.vcs != null) {
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
if (vcsRoot != null && vcsRoot.getVcs() != null) {
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
if (localChangesProvider == null) continue;
final boolean takeDirs = vcsRoot.vcs.areDirectoriesVersionedItems();
final boolean takeDirs = vcsRoot.getVcs().areDirectoriesVersionedItems();
final Collection<FilePath> files = map.get(vcsRoot);
final List<FilePath> toBeDeleted = new LinkedList<FilePath>();
@@ -142,7 +142,7 @@ public class TriggerAdditionOrDeletion {
}
}
if (toBeDeleted.isEmpty()) return;
if (! vcsRoot.vcs.fileListenerIsSynchronous()) {
if (! vcsRoot.getVcs().fileListenerIsSynchronous()) {
for (FilePath filePath : toBeDeleted) {
myVcsFileListenerContextHelper.ignoreDeleted(filePath);
}
@@ -159,15 +159,15 @@ public class TriggerAdditionOrDeletion {
final MultiMap<VcsRoot, FilePath> map = sortByVcsRoots.sort(myExisting);
myPreparedAddition = new MultiMap<VcsRoot, FilePath>();
for (VcsRoot vcsRoot : map.keySet()) {
if (vcsRoot != null && vcsRoot.vcs != null) {
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
if (vcsRoot != null && vcsRoot.getVcs() != null) {
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
if (localChangesProvider == null) continue;
final boolean takeDirs = vcsRoot.vcs.areDirectoriesVersionedItems();
final boolean takeDirs = vcsRoot.getVcs().areDirectoriesVersionedItems();
final Collection<FilePath> files = map.get(vcsRoot);
final List<FilePath> toBeAdded;
if (takeDirs) {
final RecursiveCheckAdder adder = new RecursiveCheckAdder(vcsRoot.path);
final RecursiveCheckAdder adder = new RecursiveCheckAdder(vcsRoot.getPath());
for (FilePath file : files) {
adder.process(file);
}
@@ -184,7 +184,7 @@ public class TriggerAdditionOrDeletion {
return;
}
Collections.sort(toBeAdded, FilePathByPathComparator.getInstance());
if (! vcsRoot.vcs.fileListenerIsSynchronous()) {
if (! vcsRoot.getVcs().fileListenerIsSynchronous()) {
for (FilePath filePath : toBeAdded) {
myVcsFileListenerContextHelper.ignoreAdded(filePath.getVirtualFile());
}
@@ -58,13 +58,13 @@ public class DirtBuilder implements DirtBuilderReader {
}
public void addDirtyFile(final VcsRoot root) {
if (myFileTypeManager.isFileIgnored(root.path.getName())) return;
myFiles.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
if (myFileTypeManager.isFileIgnored(root.getPath().getName())) return;
myFiles.add(new FilePathUnderVcs(new FilePathImpl(root.getPath()), root.getVcs()));
}
public void addDirtyDirRecursively(final VcsRoot root) {
if (myFileTypeManager.isFileIgnored(root.path.getName())) return;
myDirs.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
if (myFileTypeManager.isFileIgnored(root.getPath().getName())) return;
myDirs.add(new FilePathUnderVcs(new FilePathImpl(root.getPath()), root.getVcs()));
}
public void addDirtyFile(final FilePathUnderVcs root) {
@@ -33,8 +33,8 @@ public class FilePathUnderVcs {
}
FilePathUnderVcs(final VcsRoot root) {
myPath = new FilePathImpl(root.path);
myVcs = root.vcs;
myPath = new FilePathImpl(root.getPath());
myVcs = root.getVcs();
}
public FilePath getPath() {
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vcs.changes;
import com.intellij.lifecycle.AtomicSectionsAware;
import com.intellij.lifecycle.PeriodicalTasksCloser;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
@@ -128,7 +127,7 @@ public class RemoteRevisionsCache implements PlusMinus<Pair<String, AbstractVcs>
final VcsRoot[] roots = myVcsManager.getAllVcsRoots();
synchronized (myLock) {
for (VcsRoot root : roots) {
final AbstractVcs vcs = root.vcs;
final AbstractVcs vcs = root.getVcs();
if (! myKinds.containsKey(vcs.getName())) {
myKinds.put(vcs.getName(), vcs.getRemoteDifferenceStrategy());
}
@@ -96,8 +96,8 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
for (Iterator<Map.Entry<VcsRoot, LazyRefreshingSelfQueue>> iterator = copyMap.entrySet().iterator(); iterator.hasNext();) {
final Map.Entry<VcsRoot, LazyRefreshingSelfQueue> entry = iterator.next();
final VcsRoot key = entry.getKey();
final boolean backgroundOperationsAllowed = key.vcs.isVcsBackgroundOperationsAllowed(key.path);
LOG.debug("backgroundOperationsAllowed: " + backgroundOperationsAllowed + " for " + key.vcs.getName() + ", " + key.path.getPath());
final boolean backgroundOperationsAllowed = key.getVcs().isVcsBackgroundOperationsAllowed(key.getPath());
LOG.debug("backgroundOperationsAllowed: " + backgroundOperationsAllowed + " for " + key.getVcs().getName() + ", " + key.getPath().getPath());
if (! backgroundOperationsAllowed) {
iterator.remove();
}
@@ -232,7 +232,7 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
//todo check canceled - check VCS's ready for asynchronous queries
final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(s));
final ItemLatestState state;
final DiffProvider diffProvider = myVcsRoot.vcs.getDiffProvider();
final DiffProvider diffProvider = myVcsRoot.getVcs().getDiffProvider();
if (vf == null) {
// doesnt matter if directory or not
state = diffProvider.getLastRevision(FilePathImpl.createForDeletedFile(new File(s), false));
@@ -262,11 +262,11 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
}
public Boolean compute() {
final AbstractVcs vcs = myVcsRoot.vcs;
final AbstractVcs vcs = myVcsRoot.getVcs();
// won't be called in parallel for same vcs -> just synchronized map is ok
final String vcsName = vcs.getName();
LOG.debug("should update for: " + vcsName + " root: " + myVcsRoot.path.getPath());
final VcsRevisionNumber latestNew = vcs.getDiffProvider().getLatestCommittedRevision(myVcsRoot.path);
LOG.debug("should update for: " + vcsName + " root: " + myVcsRoot.getPath().getPath());
final VcsRevisionNumber latestNew = vcs.getDiffProvider().getLatestCommittedRevision(myVcsRoot.getPath());
final VcsRevisionNumber latestKnown = myLatestRevisionsMap.get(vcsName);
// not known
@@ -135,12 +135,12 @@ public class RemoteRevisionsStateCache implements ChangesOnServerTracker {
for (VcsRoot vcsRoot : dirty.keySet()) {
// todo - actually it means nothing since the only known VCS to use this scheme is Git and now it always allow
// todo - background operations. when it changes, develop more flexible behavior here
if (! vcsRoot.vcs.isVcsBackgroundOperationsAllowed(vcsRoot.path)) continue;
final TreeDiffProvider provider = vcsRoot.vcs.getTreeDiffProvider();
if (! vcsRoot.getVcs().isVcsBackgroundOperationsAllowed(vcsRoot.getPath())) continue;
final TreeDiffProvider provider = vcsRoot.getVcs().getTreeDiffProvider();
if (provider == null) continue;
final Collection<String> paths = dirty.get(vcsRoot);
final Collection<String> remotelyChanged = provider.getRemotelyChanged(vcsRoot.path, paths);
final Collection<String> remotelyChanged = provider.getRemotelyChanged(vcsRoot.getPath(), paths);
for (String path : paths) {
results.put(path, new Pair<Boolean, VcsRoot>(remotelyChanged.contains(path), vcsRoot));
}
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
@@ -307,16 +308,16 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
if (myProject.isDisposed()) return Boolean.FALSE;
final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path);
if (vcsConsumer != null && rootObject != null) {
vcsConsumer.consume(rootObject.vcs);
vcsConsumer.consume(rootObject.getVcs());
}
if (rootObject == null || rootObject.vcs != myVcs) {
if (rootObject == null || rootObject.getVcs() != myVcs) {
return Boolean.FALSE;
}
final VirtualFile vcsRoot = rootObject.path;
final VirtualFile vcsRoot = rootObject.getPath();
if (vcsRoot != null) {
for (VirtualFile contentRoot : myAffectedContentRoots) {
if (VfsUtil.isAncestor(contentRoot, vcsRoot, false)) {
if (VfsUtilCore.isAncestor(contentRoot, vcsRoot, false)) {
THashSet<FilePath> dirsByRoot = myDirtyDirectoriesRecursively.get(contentRoot);
if (dirsByRoot != null) {
for (FilePath filePath : dirsByRoot) {
@@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -87,9 +88,9 @@ public class LocalChangesUnderRoots {
}
VirtualFile rootCandidate = null;
for (VcsRoot root : myRoots) {
if (VfsUtil.isAncestor(root.path, vf, false)) {
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.path, true)) { // in the case of nested roots choose the closest root
rootCandidate = root.path;
if (VfsUtilCore.isAncestor(root.getPath(), vf, false)) {
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.getPath(), true)) { // in the case of nested roots choose the closest root
rootCandidate = root.getPath();
}
}
}
@@ -92,8 +92,8 @@ public class VcsRootIterator {
final String ourPath = myRoot.getUrl();
for (VcsRoot root : allRoots) {
if (Comparing.equal(root.vcs.getName(), myVcsName)) continue;
final String url = root.path.getUrl();
if (Comparing.equal(root.getVcs().getName(), myVcsName)) continue;
final String url = root.getPath().getUrl();
if (url.startsWith(ourPath)) {
myExcludedByOtherVcss.add(url);
}
@@ -100,12 +100,16 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
public GitRepository getRepositoryForFile(@NotNull VirtualFile file) {
final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
if (vcsRoot == null) { return null; }
final AbstractVcs vcs = vcsRoot.vcs;
final AbstractVcs vcs = vcsRoot.getVcs();
if (!myVcs.equals(vcs)) {
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs != null ? vcs.getDisplayName() : vcs, file));
if (vcs != null) {
// if null, the file is just not under version control, nothing interesting;
// otherwise log, because Git method is requested not for a Git-controlled file
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs.getDisplayName(), file));
}
return null;
}
return getRepositoryForRoot(vcsRoot.path);
return getRepositoryForRoot(vcsRoot.getPath());
}
@Override
@@ -114,7 +114,7 @@ abstract class GitChangesCollector {
protected void addToPaths(FilePath pathToAdd, List<String> paths) {
VcsRoot fileRoot = myVcsManager.getVcsRootObjectFor(pathToAdd);
if (fileRoot != null && fileRoot.vcs != null && fileRoot.vcs.equals(myVcs) && myVcsRoot.equals(fileRoot.path)) {
if (fileRoot != null && fileRoot.getVcs() != null && myVcs.equals(fileRoot.getVcs()) && myVcsRoot.equals(fileRoot.getPath())) {
paths.add(pathToAdd.getPath());
}
}
@@ -332,8 +332,8 @@ public abstract class HgUtil {
public static @NotNull List<VirtualFile> getHgRepositories(@NotNull Project project) {
final List<VirtualFile> repos = new LinkedList<VirtualFile>();
for (VcsRoot root : ProjectLevelVcsManager.getInstance(project).getAllVcsRoots()) {
if (HgVcs.VCS_NAME.equals(root.vcs.getName())) {
repos.add(root.path);
if (HgVcs.VCS_NAME.equals(root.getVcs().getName())) {
repos.add(root.getPath());
}
}
return repos;