mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
use javahg for cat command
This commit is contained in:
@@ -79,7 +79,7 @@ public class HgBlameCommand extends AbstractCommand implements BlameCommand
|
||||
* @param context
|
||||
* @param repository
|
||||
*/
|
||||
public HgBlameCommand(HgCommandContext context, Repository repository)
|
||||
HgBlameCommand(HgCommandContext context, Repository repository)
|
||||
{
|
||||
super(context, repository);
|
||||
}
|
||||
|
||||
@@ -30,23 +30,20 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
import sonia.scm.repository.HgContext;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.web.HgUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -55,22 +52,19 @@ import java.io.OutputStream;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class HgCatCommand extends AbstractHgCommand implements CatCommand
|
||||
public class HgCatCommand extends AbstractCommand implements CatCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param context
|
||||
* @param repository
|
||||
* @param repositoryDirectory
|
||||
*/
|
||||
HgCatCommand(HgRepositoryHandler handler, HgContext context,
|
||||
Repository repository, File repositoryDirectory)
|
||||
HgCatCommand(HgCommandContext context, Repository repository)
|
||||
{
|
||||
super(handler, context, repository, repositoryDirectory);
|
||||
super(context, repository);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -89,15 +83,19 @@ public class HgCatCommand extends AbstractHgCommand implements CatCommand
|
||||
public void getCatResult(CatCommandRequest request, OutputStream output)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
String revision = HgUtil.getRevision(request.getRevision());
|
||||
Process p = createHgProcess("cat", "-r", revision,
|
||||
Util.nonNull(request.getPath()));
|
||||
com.aragost.javahg.commands.CatCommand cmd =
|
||||
com.aragost.javahg.commands.CatCommand.on(open());
|
||||
|
||||
if (!Strings.isNullOrEmpty(request.getRevision()))
|
||||
{
|
||||
cmd.rev(request.getRevision());
|
||||
}
|
||||
|
||||
InputStream input = null;
|
||||
|
||||
try
|
||||
{
|
||||
handleErrorStream(p.getErrorStream());
|
||||
input = p.getInputStream();
|
||||
input = cmd.execute(request.getPath());
|
||||
ByteStreams.copy(input, output);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -135,8 +135,7 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
@Override
|
||||
public HgCatCommand getCatCommand()
|
||||
{
|
||||
return new HgCatCommand(handler, hgContextProvider.get(), repository,
|
||||
repositoryDirectory);
|
||||
return new HgCatCommand(context, repository);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -105,8 +106,8 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase
|
||||
|
||||
try
|
||||
{
|
||||
new HgCatCommand(handler, new HgContext(), repository,
|
||||
repositoryDirectory).getCatResult(request, baos);
|
||||
new HgCatCommand(new HgCommandContext(handler.getConfig(),
|
||||
repositoryDirectory), repository).getCatResult(request, baos);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user