diff src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 355:f2c11fe7f3e9

Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 06 Dec 2011 12:57:21 +0100
parents 5f9073eabf06
children 91d75e1bac9f
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Thu Dec 01 05:21:40 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Tue Dec 06 12:57:21 2011 +0100
@@ -39,6 +39,7 @@
 import org.tmatesoft.hg.internal.FilterByteChannel;
 import org.tmatesoft.hg.internal.ManifestRevision;
 import org.tmatesoft.hg.internal.PathScope;
+import org.tmatesoft.hg.internal.Preview;
 import org.tmatesoft.hg.util.ByteChannel;
 import org.tmatesoft.hg.util.CancelledException;
 import org.tmatesoft.hg.util.FileInfo;
@@ -469,6 +470,22 @@
 			is = f.newInputChannel();
 			ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192));
 			FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p));
+			Preview preview = filters.getAdapter(Preview.class);
+			if (preview != null) {
+				while (is.read(fb) != -1) {
+					fb.flip();
+					preview.preview(fb);
+					fb.clear();
+				}
+				// reset channel to read once again
+				try {
+					is.close();
+				} catch (IOException ex) {
+					repo.getContext().getLog().info(getClass(), ex, null);
+				}
+				is = f.newInputChannel();
+				fb.clear();
+			}
 			while (is.read(fb) != -1 && check.sameSoFar()) {
 				fb.flip();
 				filters.write(fb);