Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgIgnore.java @ 101:777ab7034c1b
Switch to JUnit for tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 28 Jan 2011 03:07:25 +0100 (2011-01-28) |
parents | c2ce1cfaeb9e |
children | a3a2e5deb320 |
rev | line source |
---|---|
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
2 * Copyright (c) 2010-2011 TMate Software Ltd |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
13 * For information on how to redistribute this software under |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
15 * contact TMate Software at support@svnkit.com |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.io.BufferedReader; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.io.File; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.io.FileReader; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.io.IOException; |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
23 import java.util.ArrayList; |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.util.Collections; |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
25 import java.util.List; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
26 import java.util.regex.Pattern; |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 /** |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
29 * |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
30 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
31 * @author TMate Software Ltd. |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 */ |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 public class HgIgnore { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
35 private List<Pattern> entries; |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
37 HgIgnore() { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
38 entries = Collections.emptyList(); |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
41 /* package-local */void read(File hgignoreFile) throws IOException { |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 if (!hgignoreFile.exists()) { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 return; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 } |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
45 ArrayList<Pattern> result = new ArrayList<Pattern>(entries); // start with existing |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
46 String syntax = "regex"; // or "glob" |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
47 BufferedReader fr = new BufferedReader(new FileReader(hgignoreFile)); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
48 String line; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
49 while ((line = fr.readLine()) != null) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
50 line = line.trim(); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
51 if (line.startsWith("syntax:")) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
52 syntax = line.substring("syntax:".length()).trim(); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
53 if (!"regex".equals(syntax) && !"glob".equals(syntax)) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
54 throw new IllegalStateException(line); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
55 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
56 } else if (line.length() > 0) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
57 // shall I account for local paths in the file (i.e. |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
58 // back-slashed on windows)? |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
59 int x; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
60 if ((x = line.indexOf('#')) >= 0) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
61 line = line.substring(0, x).trim(); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
62 if (line.length() == 0) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
63 continue; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
64 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
65 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
66 if ("glob".equals(syntax)) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
67 // hgignore(5) |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
68 // (http://www.selenic.com/mercurial/hgignore.5.html) says slashes '\' are escape characters, |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
69 // hence no special treatment of Windows path |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
70 // however, own attempts make me think '\' on Windows are not treated as escapes |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
71 line = glob2regex(line); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
72 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
73 result.add(Pattern.compile(line)); // case-sensitive |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 } |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
76 result.trimToSize(); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
77 entries = result; |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
80 // note, #isIgnored(), even if queried for directories and returned positive reply, may still get |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
81 // a file from that ignored folder to get examined. Thus, patterns like "bin" shall match not only a folder, |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
82 // but any file under that folder as well |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
83 // Alternatively, file walker may memorize folder is ignored and uses this information for all nested files. However, |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
84 // this approach would require walker (a) return directories (b) provide nesting information. This may become |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
85 // troublesome when one walks not over io.File, but Eclipse's IResource or any other custom VFS. |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
86 // |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
87 // |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
88 // might be interesting, although looks like of no direct use in my case |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
89 // @see http://stackoverflow.com/questions/1247772/is-there-an-equivalent-of-java-util-regex-for-glob-type-patterns |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
90 private String glob2regex(String line) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
91 assert line.length() > 0; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
92 StringBuilder sb = new StringBuilder(line.length() + 10); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
93 sb.append('^'); // help avoid matcher.find() to match 'bin' pattern in the middle of the filename |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
94 int start = 0, end = line.length() - 1; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
95 // '*' at the beginning and end of a line are useless for Pattern |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
96 while (start <= end && line.charAt(start) == '*') start++; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
97 while (end > start && line.charAt(end) == '*') end--; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
98 |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
99 for (int i = start; i <= end; i++) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
100 char ch = line.charAt(i); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
101 if (ch == '.' || ch == '\\') { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
102 sb.append('\\'); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
103 } else if (ch == '?') { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
104 // simple '.' substitution might work out, however, more formally |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
105 // a char class seems more appropriate to avoid accidentally |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
106 // matching a subdirectory with ? char (i.e. /a/b?d against /a/bad, /a/bed and /a/b/d) |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
107 // @see http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_03 |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
108 // quote: "The slash character in a pathname shall be explicitly matched by using one or more slashes in the pattern; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
109 // it shall neither be matched by the asterisk or question-mark special characters nor by a bracket expression" |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
110 sb.append("[^/]"); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
111 continue; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
112 } else if (ch == '*') { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
113 sb.append("[^/]*?"); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
114 continue; |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
115 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
116 sb.append(ch); |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
117 } |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
118 return sb.toString(); |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 public boolean isIgnored(String path) { |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
122 for (Pattern p : entries) { |
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
123 if (p.matcher(path).find()) { |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 return true; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 return false; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 } |