use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgHistoryUtil method history.
/**
* <p>Get & parse hg log detailed output with commits, their parents and their changes.
* For null destination return log command result</p>
* <p/>
* <p>Warning: this is method is efficient by speed, but don't query too much, because the whole log output is retrieved at once,
* and it can occupy too much memory. The estimate is ~600Kb for 1000 commits.</p>
*/
@NotNull
public static List<? extends VcsFullCommitDetails> history(@NotNull final Project project, @NotNull final VirtualFile root, final int limit, @NotNull List<String> hashParameters, final boolean silent) throws VcsException {
HgVcs hgvcs = HgVcs.getInstance(project);
assert hgvcs != null;
final HgVersion version = hgvcs.getVersion();
final String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
return VcsFileUtil.foreachChunk(hashParameters, 2, strings -> {
HgCommandResult logResult = getLogResult(project, root, version, limit, strings, HgChangesetUtil.makeTemplate(templates));
if (logResult == null)
return Collections.emptyList();
if (!logResult.getErrorLines().isEmpty())
throw new VcsException(logResult.getRawError());
return createFullCommitsFromResult(project, root, logResult, version, silent);
});
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgMergeCommand method mergeWith.
public static void mergeWith(@NotNull final HgRepository repository, @NotNull final String branchName, @NotNull final UpdatedFiles updatedFiles, @Nullable final Runnable onSuccessHandler) {
final Project project = repository.getProject();
final VirtualFile repositoryRoot = repository.getRoot();
final HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repository);
//there is no difference between branch or revision or bookmark as parameter to merge,
hgMergeCommand.setRevision(branchName);
// we need just a string
new Task.Backgroundable(project, "Merging Changes...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
HgCommandResult result = hgMergeCommand.mergeSynchronously();
if (HgErrorUtil.isAncestorMergeError(result)) {
//skip and notify
VcsNotifier.getInstance(project).notifyMinorWarning("Merging is skipped for " + repositoryRoot.getPresentableName(), "Merging with a working directory ancestor has no effect");
return;
}
new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot);
if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) {
// for example commit changes
onSuccessHandler.run();
}
} catch (VcsException exception) {
if (exception.isWarning()) {
VcsNotifier.getInstance(project).notifyWarning("Warning during merge", exception.getMessage());
} else {
VcsNotifier.getInstance(project).notifyError("Exception during merge", exception.getMessage());
}
}
}
}.queue();
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedNativeTest method testModificationAndAfterRevert.
@Test
public void testModificationAndAfterRevert() throws Exception {
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
sleep(100);
VcsTestUtil.editFileInCommand(myProject, subTree.myS1File, "new content");
final CharSequence text1 = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals("new content", text1.toString());
sleep(100);
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(virtualToIoFile(subTree.myS1File));
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
final VcsException updateException = ((ChangeListManagerImpl) clManager).getUpdateException();
if (updateException != null) {
updateException.printStackTrace();
}
Assert.assertNull(updateException == null ? null : updateException.getMessage(), updateException);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.myS1File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals(SubTree.ourS1Contents, text.toString());
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedTest method testModificationAndAfterRevert.
@Test
public void testModificationAndAfterRevert() throws Exception {
//ChangeListManagerImpl.DEBUG = true;
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
sleep(100);
VcsTestUtil.editFileInCommand(myProject, subTree.myS1File, "new content");
final CharSequence text1 = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals("new content", text1.toString());
sleep(100);
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(virtualToIoFile(subTree.myS1File));
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
final VcsException updateException = ((ChangeListManagerImpl) clManager).getUpdateException();
if (updateException != null) {
updateException.printStackTrace();
}
Assert.assertNull(updateException == null ? null : updateException.getMessage(), updateException);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.myS1File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals(SubTree.ourS1Contents, text.toString());
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnRenameTest method testRollbackRenameDir.
// IDEADEV-9755
@Test
public void testRollbackRenameDir() throws Exception {
final VirtualFile child = prepareDirectoriesForRename();
renameFileInCommand(child, "newchild");
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
changeListManager.ensureUpToDate(false);
final Change change = changeListManager.getChange(myWorkingCopyDir.findChild("newchild"));
Assert.assertNotNull(change);
final List<VcsException> exceptions = new ArrayList<>();
SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(Collections.singletonList(change), exceptions, RollbackProgressListener.EMPTY);
Assert.assertTrue(exceptions.isEmpty());
Assert.assertFalse(new File(myWorkingCopyDir.getPath(), "newchild").exists());
Assert.assertTrue(new File(myWorkingCopyDir.getPath(), "child").exists());
}
Aggregations