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 org
.jetbrains
.idea
.svn
;
18 import com
.intellij
.openapi
.diagnostic
.Logger
;
19 import org
.tmatesoft
.svn
.core
.SVNDepth
;
20 import org
.tmatesoft
.svn
.core
.SVNException
;
21 import org
.tmatesoft
.svn
.core
.internal
.wc
.DefaultSVNOptions
;
22 import org
.tmatesoft
.svn
.core
.wc
.ISVNStatusHandler
;
23 import org
.tmatesoft
.svn
.core
.wc
.SVNRevision
;
24 import org
.tmatesoft
.svn
.core
.wc
.SVNStatus
;
25 import org
.tmatesoft
.svn
.core
.wc
.SVNStatusType
;
30 public class IgnoredFileInfo
{
31 private static final Logger LOG
= Logger
.getInstance("#org.jetbrains.idea.svn.IgnoredFileInfo");
33 // directory for which properties are collected
34 private final File myFile
;
35 private final List
<String
> myPatterns
;
36 private final Set
<String
> myFileNames
;
37 private final Set
<String
> myOldPatterns
;
39 public IgnoredFileInfo(final File file
, final Set
<String
> oldPatterns
) {
41 myPatterns
= new ArrayList
<String
>();
42 myFileNames
= new HashSet
<String
>();
43 myOldPatterns
= oldPatterns
;
46 public void addFileName(final String name
) {
47 myFileNames
.add(name
);
50 public void addPattern(final String value
) {
51 myPatterns
.add(value
);
54 public void calculatePatterns(final SvnVcs vcs
) {
55 final List
<String
> names
= new ArrayList
<String
>();
57 vcs
.createStatusClient().doStatus(myFile
, SVNRevision
.WORKING
, SVNDepth
.IMMEDIATES
, false, true, true, false, new ISVNStatusHandler() {
58 public void handleStatus(SVNStatus status
) throws SVNException
{
59 if (SVNStatusType
.STATUS_IGNORED
== status
.getContentsStatus()) {
60 final String name
= status
.getFile().getName();
61 if (! myFileNames
.contains(name
)) {
68 catch (SVNException e
) {
72 for (String pattern
: myOldPatterns
) {
73 boolean usedSomewhereElse
= false;
74 for (String name
: names
) {
75 if (DefaultSVNOptions
.matches(pattern
, name
)) {
76 usedSomewhereElse
= true;
81 if (! usedSomewhereElse
) {
82 for (String name
: myFileNames
) {
83 if (DefaultSVNOptions
.matches(pattern
, name
)) {
84 myPatterns
.add(pattern
);
92 public File
getFile() {
96 public List
<String
> getPatterns() {
100 public Set
<String
> getFileNames() {
104 public Set
<String
> getOldPatterns() {
105 return myOldPatterns
;