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