Add raw stream result to cat command

This commit is contained in:
René Pfeuffer
2018-08-14 17:22:30 +02:00
parent 2266b971a9
commit c8c1cad67f
5 changed files with 134 additions and 80 deletions

View File

@@ -37,17 +37,16 @@ package sonia.scm.repository.spi;
import com.google.common.io.ByteStreams;
import com.google.common.io.Closeables;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.web.HgUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
@@ -83,16 +82,9 @@ public class HgCatCommand extends AbstractCommand implements CatCommand
public void getCatResult(CatCommandRequest request, OutputStream output)
throws IOException, RepositoryException
{
com.aragost.javahg.commands.CatCommand cmd =
com.aragost.javahg.commands.CatCommand.on(open());
cmd.rev(HgUtil.getRevision(request.getRevision()));
InputStream input = null;
InputStream input = getCatResultStream(request);
try
{
input = cmd.execute(request.getPath());
ByteStreams.copy(input, output);
}
finally
@@ -100,4 +92,14 @@ public class HgCatCommand extends AbstractCommand implements CatCommand
Closeables.close(input, true);
}
}
@Override
public InputStream getCatResultStream(CatCommandRequest request) throws IOException, RepositoryException {
com.aragost.javahg.commands.CatCommand cmd =
com.aragost.javahg.commands.CatCommand.on(open());
cmd.rev(HgUtil.getRevision(request.getRevision()));
return cmd.execute(request.getPath());
}
}