2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.vcs
.impl
.projectlevelman
;
18 import com
.intellij
.openapi
.diff
.impl
.patch
.formove
.FilePathComparator
;
19 import com
.intellij
.openapi
.project
.Project
;
20 import com
.intellij
.openapi
.vcs
.AbstractVcs
;
21 import com
.intellij
.openapi
.vcs
.impl
.ExcludedFileIndex
;
22 import com
.intellij
.openapi
.vfs
.VfsUtil
;
23 import com
.intellij
.openapi
.vfs
.VirtualFile
;
25 import java
.util
.Collections
;
26 import java
.util
.List
;
28 public class MappingsToRoots
{
29 private final NewMappings myMappings
;
30 private final Project myProject
;
32 public MappingsToRoots(final NewMappings mappings
, final Project project
) {
33 myMappings
= mappings
;
37 public VirtualFile
[] getRootsUnderVcs(final AbstractVcs vcs
) {
38 List
<VirtualFile
> result
= myMappings
.getMappingsAsFilesUnderVcs(vcs
);
40 final AbstractVcs
.RootsConvertor convertor
= vcs
.getCustomConvertor();
41 if (convertor
!= null) {
42 result
= convertor
.convertRoots(result
);
45 Collections
.sort(result
, FilePathComparator
.getInstance());
46 if (! vcs
.allowsNestedRoots()) {
48 while(i
< result
.size()) {
49 final VirtualFile previous
= result
.get(i
- 1);
50 final VirtualFile current
= result
.get(i
);
51 if (ExcludedFileIndex
.getInstance(myProject
).isValidAncestor(previous
, current
)) {
52 // if (ExcludedFileIndex.getInstance(myProject).isValidAncestor(previous, current) && vcs.isVersionedDirectory(previous)) {
60 return VfsUtil
.toVirtualFileArray(result
);