mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
use javahg for diff command
This commit is contained in:
@@ -30,46 +30,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.base.Strings;
|
||||||
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;
|
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class HgDiffCommand extends AbstractHgCommand implements DiffCommand
|
public class HgDiffCommand extends AbstractCommand implements DiffCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param handler
|
|
||||||
* @param context
|
* @param context
|
||||||
* @param repository
|
* @param repository
|
||||||
* @param repositoryDirectory
|
|
||||||
*/
|
*/
|
||||||
public HgDiffCommand(HgRepositoryHandler handler, HgContext context,
|
HgDiffCommand(HgCommandContext context, Repository repository)
|
||||||
Repository repository, File repositoryDirectory)
|
|
||||||
{
|
{
|
||||||
super(handler, context, repository, repositoryDirectory);
|
super(context, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -88,19 +80,25 @@ public class HgDiffCommand extends AbstractHgCommand implements DiffCommand
|
|||||||
public void getDiffResult(DiffCommandRequest request, OutputStream output)
|
public void getDiffResult(DiffCommandRequest request, OutputStream output)
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Process p = createHgProcess("diff", "-c", request.getRevision(),
|
com.aragost.javahg.commands.DiffCommand cmd =
|
||||||
Util.nonNull(request.getPath()));
|
com.aragost.javahg.commands.DiffCommand.on(open());
|
||||||
InputStream input = null;
|
|
||||||
|
|
||||||
try
|
if (!Strings.isNullOrEmpty(request.getRevision()))
|
||||||
{
|
{
|
||||||
handleErrorStream(p.getErrorStream());
|
cmd.change(request.getRevision());
|
||||||
input = p.getInputStream();
|
|
||||||
ByteStreams.copy(input, output);
|
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
|
String diff = null;
|
||||||
|
|
||||||
|
if (!Strings.isNullOrEmpty(request.getPath()))
|
||||||
{
|
{
|
||||||
Closeables.closeQuietly(input);
|
diff = cmd.execute(request.getPath());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diff = cmd.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
output.write(diff.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
|||||||
@Override
|
@Override
|
||||||
public HgDiffCommand getDiffCommand()
|
public HgDiffCommand getDiffCommand()
|
||||||
{
|
{
|
||||||
return new HgDiffCommand(handler, hgContextProvider.get(), repository,
|
return new HgDiffCommand(context, repository);
|
||||||
repositoryDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user