1 package com
.intellij
.openapi
.vcs
.impl
;
3 import com
.intellij
.openapi
.project
.Project
;
4 import com
.intellij
.openapi
.vcs
.AbstractVcs
;
5 import com
.intellij
.openapi
.vcs
.FilePathImpl
;
6 import com
.intellij
.openapi
.vcs
.changes
.DirtBuilder
;
7 import com
.intellij
.openapi
.vcs
.changes
.VcsGuess
;
8 import com
.intellij
.openapi
.vcs
.changes
.FilePathUnderVcs
;
9 import com
.intellij
.openapi
.vcs
.impl
.projectlevelman
.NewMappings
;
10 import com
.intellij
.openapi
.vfs
.VfsUtil
;
11 import com
.intellij
.openapi
.vfs
.VirtualFile
;
12 import com
.intellij
.platform
.ProjectBaseDirectory
;
13 import org
.jetbrains
.annotations
.Nullable
;
15 import java
.util
.List
;
20 public class BasicDefaultVcsRootPolicy
extends DefaultVcsRootPolicy
{
21 private final Project myProject
;
22 private final VirtualFile myBaseDir
;
24 public BasicDefaultVcsRootPolicy(Project project
) {
26 myBaseDir
= project
.getBaseDir();
29 public void addDefaultVcsRoots(final NewMappings mappingList
, final AbstractVcs vcs
, final List
<VirtualFile
> result
) {
30 final VirtualFile baseDir
= ProjectBaseDirectory
.getInstance(myProject
).getBaseDir(myBaseDir
);
31 if (baseDir
!= null && vcs
.getName().equals(mappingList
.getVcsFor(baseDir
))) {
36 public boolean matchesDefaultMapping(final VirtualFile file
, final Object matchContext
) {
37 return VfsUtil
.isAncestor(ProjectBaseDirectory
.getInstance(myProject
).getBaseDir(myBaseDir
), file
, false);
41 public Object
getMatchContext(final VirtualFile file
) {
46 public VirtualFile
getVcsRootFor(final VirtualFile file
) {
47 return ProjectBaseDirectory
.getInstance(myProject
).getBaseDir(myBaseDir
);
50 public void markDefaultRootsDirty(final DirtBuilder builder
, final VcsGuess vcsGuess
) {
51 final FilePathImpl fp
= new FilePathImpl(ProjectBaseDirectory
.getInstance(myProject
).getBaseDir(myBaseDir
));
52 final AbstractVcs vcs
= vcsGuess
.getVcsForDirty(fp
);
54 builder
.addDirtyDirRecursively(new FilePathUnderVcs(fp
, vcs
));