Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgDataFile.java @ 121:b1d6208fb517
Conditionally apply filters to file content
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 04 Feb 2011 03:37:09 +0100 |
parents | c0cc2535462c |
children | 645829962785 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgDataFile.java Fri Feb 04 03:23:47 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgDataFile.java Fri Feb 04 03:37:09 2011 +0100 @@ -25,6 +25,7 @@ import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.core.Path; +import org.tmatesoft.hg.internal.FilterByteChannel; import org.tmatesoft.hg.internal.RevlogStream; import org.tmatesoft.hg.util.ByteChannel; @@ -73,15 +74,18 @@ return content(TIP); } - public void content(int revision, ByteChannel sink) throws /*TODO typed*/Exception { + /*XXX not sure applyFilters is the best way to do, perhaps, callers shall add filters themselves?*/ + public void content(int revision, ByteChannel sink, boolean applyFilters) throws /*TODO typed*/Exception { byte[] content = content(revision); ByteBuffer buf = ByteBuffer.allocate(512); int left = content.length; int offset = 0; + ByteChannel _sink = applyFilters ? new FilterByteChannel(sink, getRepo().getFiltersFromRepoToWorkingDir(getPath())) : sink; do { buf.put(content, offset, Math.min(left, buf.remaining())); buf.flip(); - int consumed = sink.write(buf); + // XXX I may not rely on returned number of bytes but track change in buf position instead. + int consumed = _sink.write(buf); buf.compact(); offset += consumed; left -= consumed;