changeset 118:68ba22a2133a

Defects in the filter initialization
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 04 Feb 2011 02:44:32 +0100
parents 6c0be854d149
children ed2b4adac51c
files src/org/tmatesoft/hg/internal/KeywordFilter.java src/org/tmatesoft/hg/internal/NewlineFilter.java src/org/tmatesoft/hg/internal/PathGlobMatcher.java
diffstat 3 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/KeywordFilter.java	Fri Feb 04 02:12:30 2011 +0100
+++ b/src/org/tmatesoft/hg/internal/KeywordFilter.java	Fri Feb 04 02:44:32 2011 +0100
@@ -289,7 +289,7 @@
 
 		public Filter create(Path path, Options opts) {
 			if (matcher.accept(path)) {
-				return new KeywordFilter(repo, path, true);
+				return new KeywordFilter(repo, path, opts.getDirection() == Filter.Direction.FromRepo);
 			}
 			return null;
 		}
--- a/src/org/tmatesoft/hg/internal/NewlineFilter.java	Fri Feb 04 02:12:30 2011 +0100
+++ b/src/org/tmatesoft/hg/internal/NewlineFilter.java	Fri Feb 04 02:44:32 2011 +0100
@@ -167,7 +167,7 @@
 
 		public void initialize(HgRepository hgRepo, ConfigFile cfg) {
 			failIfInconsistent = cfg.getBoolean("eol", "only-consistent", true);
-			File cfgFile = new File(new HgInternals(hgRepo).getRepositoryDir(), ".hgeol");
+			File cfgFile = new File(new HgInternals(hgRepo).getRepositoryDir().getParentFile(), ".hgeol");
 			if (!cfgFile.canRead()) {
 				return;
 			}
--- a/src/org/tmatesoft/hg/internal/PathGlobMatcher.java	Fri Feb 04 02:12:30 2011 +0100
+++ b/src/org/tmatesoft/hg/internal/PathGlobMatcher.java	Fri Feb 04 02:44:32 2011 +0100
@@ -58,12 +58,16 @@
 		boolean needLineEndMatch = glob.charAt(end) != '*';
 		while (end > 0 && glob.charAt(end) == '*') end--; // remove trailing * that are useless for Pattern.find()
 		StringBuilder sb = new StringBuilder(end*2);
+		if (glob.charAt(0) != '*') {
+			sb.append('^');
+		}
 		for (int i = 0; i <= end; i++) {
 			char ch = glob.charAt(i);
 			if (ch == '*') {
 				if (glob.charAt(i+1) == '*') { // i < end because we've stripped any trailing * earlier
 					// any char, including path segment separator
 					sb.append(".*?");
+					i++;
 				} else {
 					// just path segments
 					sb.append("[^/]*?");