# HG changeset patch # User Artem Tikhomirov # Date 1315829505 -7200 # Node ID 086a326f181f8e1190e6f0acfc3136262b076236 # Parent b11f6a08f7488d69aacfc2b2d3f3daaf376226a5 Provide public access to ignored files configuration to use in alternative file walkers diff -r b11f6a08f748 -r 086a326f181f src/org/tmatesoft/hg/repo/HgIgnore.java --- a/src/org/tmatesoft/hg/repo/HgIgnore.java Sat Sep 10 00:18:39 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgIgnore.java Mon Sep 12 14:11:45 2011 +0200 @@ -33,7 +33,7 @@ * @author Artem Tikhomirov * @author TMate Software Ltd. */ -public class HgIgnore { +public class HgIgnore implements Path.Matcher { private List entries; @@ -104,7 +104,9 @@ // // might be interesting, although looks like of no direct use in my case // @see http://stackoverflow.com/questions/1247772/is-there-an-equivalent-of-java-util-regex-for-glob-type-patterns - private String glob2regex(String line) { + // + // TODO consider refactoring to reuse in PathGlobMatcher#glob2regexp + private static String glob2regex(String line) { assert line.length() > 0; StringBuilder sb = new StringBuilder(line.length() + 10); if (line.charAt(0) != '*') { @@ -154,7 +156,10 @@ return sb.toString(); } - // TODO use PathGlobMatcher + /** + * @param path file or directory name in question + * @return true if matches repository configuration of ignored files. + */ public boolean isIgnored(Path path) { for (Pattern p : entries) { if (p.matcher(path).find()) { @@ -163,4 +168,12 @@ } return false; } + + /** + * A handy wrap of {@link #isIgnored(Path)} into {@link Path.Matcher}. Yields same result as {@link #isIgnored(Path)}. + * @return true if file is deemed ignored. + */ + public boolean accept(Path path) { + return isIgnored(path); + } } diff -r b11f6a08f748 -r 086a326f181f src/org/tmatesoft/hg/repo/HgRepository.java --- a/src/org/tmatesoft/hg/repo/HgRepository.java Sat Sep 10 00:18:39 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Mon Sep 12 14:11:45 2011 +0200 @@ -276,8 +276,11 @@ return new HgDirstate(this, new File(repoDir, "dirstate"), pathPool); } - // package-local, see comment for loadDirstate - /*package-local*/ final HgIgnore getIgnore() { + /** + * Access to configured set of ignored files. + * @see HgIgnore#isIgnored(Path) + */ + public HgIgnore getIgnore() { // TODO read config for additional locations if (ignore == null) { ignore = new HgIgnore();