diff src/org/tmatesoft/hg/repo/HgInternals.java @ 414:bb278ccf9866

Pull changes from smartgit3 branch
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 21 Mar 2012 20:51:12 +0100
parents 866fc3b597a0 63c5a9d7ca3f
children 9c9c442b5f2e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgInternals.java	Wed Mar 21 20:40:28 2012 +0100
+++ b/src/org/tmatesoft/hg/repo/HgInternals.java	Wed Mar 21 20:51:12 2012 +0100
@@ -29,7 +29,9 @@
 import org.tmatesoft.hg.core.HgInvalidRevisionException;
 import org.tmatesoft.hg.core.SessionContext;
 import org.tmatesoft.hg.internal.Experimental;
+import org.tmatesoft.hg.internal.Internals;
 import org.tmatesoft.hg.internal.RelativePathRewrite;
+import org.tmatesoft.hg.internal.WinToNixPathRewrite;
 import org.tmatesoft.hg.util.FileIterator;
 import org.tmatesoft.hg.util.FileWalker;
 import org.tmatesoft.hg.util.Path;
@@ -71,7 +73,7 @@
 			};
 		}
 		HgDirstate ds = new HgDirstate(repo, new File(repo.getRepositoryRoot(), "dirstate"), new PathPool(new PathRewrite.Empty()), canonicalPath);
-		ds.read();
+		ds.read(repo.getImplHelper().buildFileNameEncodingHelper());
 		return ds;
 	}
 	
@@ -87,8 +89,22 @@
 		return hgRepo.getRepositoryRoot();
 	}
 	
-	public static HgIgnore newHgIgnore(Reader source) throws IOException {
-		HgIgnore hgIgnore = new HgIgnore();
+	/**
+	 * @param source where to read definitions from
+	 * @param globPathRewrite <code>null</code> to use default, or pass an instance to override defaults
+	 * @return
+	 * @throws IOException
+	 */
+	public static HgIgnore newHgIgnore(Reader source, PathRewrite globPathRewrite) throws IOException {
+		if (globPathRewrite == null) {
+			// shall match that of HgRepository#getIgnore() (Internals#buildNormalizePathRewrite())
+			if (Internals.runningOnWindows()) {
+				globPathRewrite = new WinToNixPathRewrite();
+			} else {
+				globPathRewrite = new PathRewrite.Empty();
+			}
+		}
+		HgIgnore hgIgnore = new HgIgnore(globPathRewrite);
 		BufferedReader br = source instanceof BufferedReader ? (BufferedReader) source : new BufferedReader(source);
 		hgIgnore.read(br);
 		br.close();