mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-127320 Hg: Notify about starting and finishing VCS operations which modify the working copy files
* rebase command optimized
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.<String>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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "<html>Your uncommitted changes couldn't be merged into the requested changeset.<br>" +
|
||||
"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 = "<html>Your uncommitted changes couldn't be merged into the requested changeset.<br>" +
|
||||
"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);
|
||||
|
||||
@@ -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<FilePath> files,
|
||||
List<VcsException> exceptions, RollbackProgressListener listener) {
|
||||
revert(files);
|
||||
List<VcsException> exceptions, RollbackProgressListener listener) {
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
revert(files);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
}
|
||||
}
|
||||
|
||||
public void rollbackModifiedWithoutCheckout(List<VirtualFile> files,
|
||||
|
||||
Reference in New Issue
Block a user