Mercurial > jhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
354:5f9073eabf06 | 355:f2c11fe7f3e9 |
---|---|
37 import org.tmatesoft.hg.internal.ByteArrayChannel; | 37 import org.tmatesoft.hg.internal.ByteArrayChannel; |
38 import org.tmatesoft.hg.internal.Experimental; | 38 import org.tmatesoft.hg.internal.Experimental; |
39 import org.tmatesoft.hg.internal.FilterByteChannel; | 39 import org.tmatesoft.hg.internal.FilterByteChannel; |
40 import org.tmatesoft.hg.internal.ManifestRevision; | 40 import org.tmatesoft.hg.internal.ManifestRevision; |
41 import org.tmatesoft.hg.internal.PathScope; | 41 import org.tmatesoft.hg.internal.PathScope; |
42 import org.tmatesoft.hg.internal.Preview; | |
42 import org.tmatesoft.hg.util.ByteChannel; | 43 import org.tmatesoft.hg.util.ByteChannel; |
43 import org.tmatesoft.hg.util.CancelledException; | 44 import org.tmatesoft.hg.util.CancelledException; |
44 import org.tmatesoft.hg.util.FileInfo; | 45 import org.tmatesoft.hg.util.FileInfo; |
45 import org.tmatesoft.hg.util.FileIterator; | 46 import org.tmatesoft.hg.util.FileIterator; |
46 import org.tmatesoft.hg.util.FileWalker; | 47 import org.tmatesoft.hg.util.FileWalker; |
467 Check check = new Check(); | 468 Check check = new Check(); |
468 try { | 469 try { |
469 is = f.newInputChannel(); | 470 is = f.newInputChannel(); |
470 ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192)); | 471 ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192)); |
471 FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p)); | 472 FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p)); |
473 Preview preview = filters.getAdapter(Preview.class); | |
474 if (preview != null) { | |
475 while (is.read(fb) != -1) { | |
476 fb.flip(); | |
477 preview.preview(fb); | |
478 fb.clear(); | |
479 } | |
480 // reset channel to read once again | |
481 try { | |
482 is.close(); | |
483 } catch (IOException ex) { | |
484 repo.getContext().getLog().info(getClass(), ex, null); | |
485 } | |
486 is = f.newInputChannel(); | |
487 fb.clear(); | |
488 } | |
472 while (is.read(fb) != -1 && check.sameSoFar()) { | 489 while (is.read(fb) != -1 && check.sameSoFar()) { |
473 fb.flip(); | 490 fb.flip(); |
474 filters.write(fb); | 491 filters.write(fb); |
475 fb.compact(); | 492 fb.compact(); |
476 } | 493 } |