diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMergeCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMergeCommand.java index fdd4e6cb67c2..16c8b7fe0a8b 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMergeCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMergeCommand.java @@ -12,6 +12,7 @@ // limitations under the License. package org.zmlx.hg4idea.command; +import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -49,9 +50,15 @@ public class HgMergeCommand { arguments.add("--rev"); arguments.add(revision); } - final HgCommandResult result = - commandExecutor.executeInCurrentThread(repo, "merge", arguments); - project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); - return result; + DvcsUtil.workingTreeChangeStarted(project); + try { + final HgCommandResult result = + commandExecutor.executeInCurrentThread(repo, "merge", arguments); + project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); + return result; + } + finally { + DvcsUtil.workingTreeChangeFinished(project); + } } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRebaseCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRebaseCommand.java index c61b014cc482..05a5ebda6d7a 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRebaseCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRebaseCommand.java @@ -12,7 +12,10 @@ // limitations under the License. package org.zmlx.hg4idea.command; +import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.project.Project; +import com.intellij.util.ArrayUtil; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgVcs; @@ -20,9 +23,6 @@ import org.zmlx.hg4idea.execution.HgCommandExecutor; import org.zmlx.hg4idea.execution.HgCommandResult; import org.zmlx.hg4idea.repo.HgRepository; -import java.util.Arrays; -import java.util.Collections; - public class HgRebaseCommand { @NotNull private final Project project; @@ -35,28 +35,32 @@ public class HgRebaseCommand { @Nullable public HgCommandResult startRebase() { - HgCommandResult result = - new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", Collections.emptyList()); - repo.update(); - project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); - return result; + return performRebase(ArrayUtil.EMPTY_STRING_ARRAY); } @Nullable public HgCommandResult continueRebase() { - HgCommandResult result = - new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", Arrays.asList("--continue")); - repo.update(); - project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); - return result; + return performRebase("--continue"); } @Nullable public HgCommandResult abortRebase() { - HgCommandResult result = - new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", Arrays.asList("--abort")); - repo.update(); - project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); - return result; + return performRebase("--abort"); + } + + @Nullable + private HgCommandResult performRebase(@NotNull String... args) { + DvcsUtil.workingTreeChangeStarted(project); + try { + HgCommandResult result = + new HgCommandExecutor(project) + .executeInCurrentThread(repo.getRoot(), "rebase", ContainerUtil.list(args)); + repo.update(); + project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); + return result; + } + finally { + DvcsUtil.workingTreeChangeFinished(project); + } } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java index b41f00273935..0be4e1602b1e 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java @@ -12,6 +12,7 @@ // limitations under the License. package org.zmlx.hg4idea.command; +import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; @@ -73,16 +74,23 @@ public class HgUpdateCommand { final HgPromptCommandExecutor executor = new HgPromptCommandExecutor(project); executor.setShowOutput(true); - HgCommandResult result = - executor.executeInCurrentThread(repo, "update", arguments); - if (!clean && hasUncommittedChangesConflict(result)) { - final String message = "Your uncommitted changes couldn't be merged into the requested changeset.
" + - "Would you like to perform force update and discard them?"; - if (showDiscardChangesConfirmation(project, message) == Messages.OK) { - arguments.add("-C"); - result = executor.executeInCurrentThread(repo, "update", arguments); + HgCommandResult result; + DvcsUtil.workingTreeChangeStarted(project); + try { + result = + executor.executeInCurrentThread(repo, "update", arguments); + if (!clean && hasUncommittedChangesConflict(result)) { + final String message = "Your uncommitted changes couldn't be merged into the requested changeset.
" + + "Would you like to perform force update and discard them?"; + if (showDiscardChangesConfirmation(project, message) == Messages.OK) { + arguments.add("-C"); + result = executor.executeInCurrentThread(repo, "update", arguments); + } } } + finally { + DvcsUtil.workingTreeChangeFinished(project); + } project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); VfsUtil.markDirtyAndRefresh(true, true, false, repo); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgRollbackEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgRollbackEnvironment.java index 4890a12f5d4d..958bac8ef515 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgRollbackEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgRollbackEnvironment.java @@ -12,6 +12,7 @@ // limitations under the License. package org.zmlx.hg4idea.provider; +import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vcs.FilePath; @@ -70,28 +71,40 @@ public class HgRollbackEnvironment implements RollbackEnvironment { } } } - revert(filePaths); - for (FilePath file : toDelete) { - listener.accept(file); - try { - final File ioFile = file.getIOFile(); - if (ioFile.exists()) { - if (!ioFile.delete()) { - //noinspection ThrowableInstanceNeverThrown - vcsExceptions.add(new VcsException("Unable to delete file: " + file)); + DvcsUtil.workingTreeChangeStarted(project); + try { + revert(filePaths); + for (FilePath file : toDelete) { + listener.accept(file); + try { + final File ioFile = file.getIOFile(); + if (ioFile.exists()) { + if (!ioFile.delete()) { + //noinspection ThrowableInstanceNeverThrown + vcsExceptions.add(new VcsException("Unable to delete file: " + file)); + } } } + catch (Exception e) { + //noinspection ThrowableInstanceNeverThrown + vcsExceptions.add(new VcsException("Unable to delete file: " + file, e)); + } } - catch (Exception e) { - //noinspection ThrowableInstanceNeverThrown - vcsExceptions.add(new VcsException("Unable to delete file: " + file, e)); - } + } + finally { + DvcsUtil.workingTreeChangeFinished(project); } } public void rollbackMissingFileDeletion(List files, - List exceptions, RollbackProgressListener listener) { - revert(files); + List exceptions, RollbackProgressListener listener) { + DvcsUtil.workingTreeChangeStarted(project); + try { + revert(files); + } + finally { + DvcsUtil.workingTreeChangeFinished(project); + } } public void rollbackModifiedWithoutCheckout(List files,