Search in sources :

Example 31 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgQRenameCommand method performPatchRename.

public static void performPatchRename(@NotNull final HgRepository repository, @NotNull final String oldName, @NotNull final String newName) {
    if (oldName.equals(newName))
        return;
    final Project project = repository.getProject();
    new HgCommandExecutor(project).execute(repository.getRoot(), "qrename", Arrays.asList(oldName, newName), new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
                new HgCommandResultNotifier(project).notifyError(result, "Qrename command failed", "Could not rename patch " + oldName + " to " + newName);
            }
            repository.update();
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 32 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgRevertTest method testRevertToCurrentRevision.

@Test
public void testRevertToCurrentRevision() throws Exception {
    fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
    runHgOnProjectRepo("add", ".");
    runHgOnProjectRepo("commit", "-m", "initial contents");
    fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
    HgRevertCommand revertCommand = new HgRevertCommand(myProject);
    revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), null, false);
    HgCatCommand catCommand = new HgCatCommand(myProject);
    HgCommandResult result = catCommand.execute(getHgFile("file.txt"), null, Charset.defaultCharset());
    assertNotNull(result);
    assertEquals(result.getRawOutput(), "initial contents");
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCatCommand(org.zmlx.hg4idea.command.HgCatCommand) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) File(java.io.File) Test(org.testng.annotations.Test)

Example 33 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgRevertTest method testRevertToGivenRevision.

@Test
public void testRevertToGivenRevision() throws Exception {
    fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
    runHgOnProjectRepo("add", ".");
    runHgOnProjectRepo("commit", "-m", "initial contents");
    fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
    runHgOnProjectRepo("commit", "-m", "new contents");
    HgRevertCommand revertCommand = new HgRevertCommand(myProject);
    revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), HgRevisionNumber.getLocalInstance("0"), false);
    HgCatCommand catCommand = new HgCatCommand(myProject);
    HgCommandResult result = catCommand.execute(getHgFile("file.txt"), HgRevisionNumber.getLocalInstance("0"), Charset.defaultCharset());
    assertNotNull(result);
    assertEquals(result.getRawOutput(), "initial contents");
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCatCommand(org.zmlx.hg4idea.command.HgCatCommand) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) File(java.io.File) Test(org.testng.annotations.Test)

Example 34 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgAnnotateCommand method execute.

public List<HgAnnotationLine> execute(@NotNull HgFile hgFile, @Nullable HgRevisionNumber revision) {
    final List<String> arguments = new ArrayList<>();
    arguments.add("-cvnudl");
    HgVcs vcs = HgVcs.getInstance(myProject);
    if (vcs != null && vcs.getProjectSettings().isWhitespacesIgnoredInAnnotations() && vcs.getVersion().isIgnoreWhitespaceDiffInAnnotationsSupported()) {
        arguments.add("-w");
    }
    if (revision != null) {
        arguments.add("-r");
        arguments.add(revision.getChangeset());
    }
    arguments.add(hgFile.getRelativePath());
    final HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(hgFile.getRepo(), "annotate", arguments);
    if (result == null) {
        return Collections.emptyList();
    }
    List<String> outputLines = result.getOutputLines();
    return parse(outputLines);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgVcs(org.zmlx.hg4idea.HgVcs) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) ArrayList(java.util.ArrayList)

Example 35 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgBookmarkCommand method executeBookmarkCommandSynchronously.

private static void executeBookmarkCommandSynchronously(@NotNull Project project, @NotNull VirtualFile repositoryRoot, @NotNull String name, @NotNull List<String> args) {
    ArrayList<String> arguments = ContainerUtil.newArrayList(args);
    arguments.add(name);
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repositoryRoot, "bookmark", arguments);
    getRepositoryManager(project).updateRepository(repositoryRoot);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Hg Error", String.format("Hg bookmark command failed for repository %s with name %s ", repositoryRoot.getName(), name));
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Aggregations

HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)54 HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)21 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)19 Project (com.intellij.openapi.project.Project)12 NotNull (org.jetbrains.annotations.NotNull)11 ArrayList (java.util.ArrayList)7 HgVersion (org.zmlx.hg4idea.util.HgVersion)7 VcsException (com.intellij.openapi.vcs.VcsException)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)5 LinkedList (java.util.LinkedList)5 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)5 AccessToken (com.intellij.openapi.application.AccessToken)4 Nullable (org.jetbrains.annotations.Nullable)4 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)4 HgVcs (org.zmlx.hg4idea.HgVcs)4 HgRevertCommand (org.zmlx.hg4idea.command.HgRevertCommand)4 SmartList (com.intellij.util.SmartList)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgRemoteCommandExecutor (org.zmlx.hg4idea.execution.HgRemoteCommandExecutor)3