use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class MultipleFileMergeDialog method showMergeDialog.
private void showMergeDialog() {
DiffRequestFactory requestFactory = DiffRequestFactory.getInstance();
Collection<VirtualFile> files = myTable.getSelection();
if (!beforeResolve(files)) {
return;
}
for (final VirtualFile file : files) {
final MergeData mergeData;
try {
mergeData = myProvider.loadRevisions(file);
} catch (VcsException ex) {
Messages.showErrorDialog(myRootPanel, "Error loading revisions to merge: " + ex.getMessage());
break;
}
if (mergeData.CURRENT == null || mergeData.LAST == null || mergeData.ORIGINAL == null) {
Messages.showErrorDialog(myRootPanel, "Error loading revisions to merge");
break;
}
String leftTitle = myMergeDialogCustomizer.getLeftPanelTitle(file);
String baseTitle = myMergeDialogCustomizer.getCenterPanelTitle(file);
String rightTitle = myMergeDialogCustomizer.getRightPanelTitle(file, mergeData.LAST_REVISION_NUMBER);
String title = myMergeDialogCustomizer.getMergeWindowTitle(file);
final List<byte[]> byteContents = ContainerUtil.list(mergeData.CURRENT, mergeData.ORIGINAL, mergeData.LAST);
List<String> contentTitles = ContainerUtil.list(leftTitle, baseTitle, rightTitle);
Consumer<MergeResult> callback = result -> {
Document document = FileDocumentManager.getInstance().getCachedDocument(file);
if (document != null)
FileDocumentManager.getInstance().saveDocument(document);
checkMarkModifiedProject(file);
if (result != MergeResult.CANCEL) {
ApplicationManager.getApplication().runWriteAction(() -> {
markFileProcessed(file, getSessionResolution(result));
});
}
};
MergeRequest request;
try {
if (myProvider.isBinary(file)) {
// respect MIME-types in svn
request = requestFactory.createBinaryMergeRequest(myProject, file, byteContents, title, contentTitles, callback);
} else {
request = requestFactory.createMergeRequest(myProject, file, byteContents, title, contentTitles, callback);
}
MergeUtil.putRevisionInfos(request, mergeData);
} catch (InvalidDiffRequestException e) {
LOG.error(e);
Messages.showErrorDialog(myRootPanel, "Can't show merge dialog");
break;
}
DiffManager.getInstance().showMerge(myProject, request);
}
updateModelFromFiles();
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class VcsHandleType method processFiles.
public void processFiles(final Collection<VirtualFile> files, @Nullable final String changelist) {
try {
EditFileProvider provider = myVcs.getEditFileProvider();
assert provider != null;
provider.editFiles(VfsUtil.toVirtualFileArray(files));
} catch (VcsException e) {
Messages.showErrorDialog(VcsBundle.message("message.text.cannot.edit.file", e.getLocalizedMessage()), VcsBundle.message("message.title.edit.files"));
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
for (final VirtualFile file : files) {
file.refresh(false, false);
}
}
});
if (changelist != null) {
myChangeListManager.invokeAfterUpdate(new Runnable() {
@Override
public void run() {
LocalChangeList list = myChangeListManager.findChangeList(changelist);
if (list != null) {
List<Change> changes = ContainerUtil.mapNotNull(files, myChangeFunction);
myChangeListManager.moveChangesTo(list, changes.toArray(new Change[changes.size()]));
}
}
}, InvokeAfterUpdateMode.SILENT, "", ModalityState.NON_MODAL);
}
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class VcsLogFilterer method getFilteredDetailsFromTheVcs.
@NotNull
private static Collection<CommitId> getFilteredDetailsFromTheVcs(@NotNull Map<VirtualFile, VcsLogProvider> providers, @NotNull VcsLogFilterCollection filterCollection, int maxCount) throws VcsException {
Set<VirtualFile> visibleRoots = VcsLogUtil.getAllVisibleRoots(providers.keySet(), filterCollection.getRootFilter(), filterCollection.getStructureFilter());
Collection<CommitId> commits = ContainerUtil.newArrayList();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : providers.entrySet()) {
final VirtualFile root = entry.getKey();
if (!visibleRoots.contains(root) || (filterCollection.getUserFilter() != null && filterCollection.getUserFilter().getUsers(root).isEmpty())) {
// there is a structure or user filter, but it doesn't match this root
continue;
}
VcsLogFilterCollection rootSpecificCollection = filterCollection;
if (rootSpecificCollection.getStructureFilter() != null) {
rootSpecificCollection = new VcsLogFilterCollectionBuilder(filterCollection).with(new VcsLogStructureFilterImpl(ContainerUtil.newHashSet(VcsLogUtil.getFilteredFilesForRoot(root, filterCollection)))).build();
}
List<TimedVcsCommit> matchingCommits = entry.getValue().getCommitsMatchingFilter(root, rootSpecificCollection, maxCount);
commits.addAll(ContainerUtil.map(matchingCommits, commit -> new CommitId(commit.getId(), root)));
}
return commits;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class CvsContentRevision method getContentAsBytes.
@Nullable
@Override
public byte[] getContentAsBytes() throws VcsException {
if (myContent == null) {
final GetFileContentOperation operation = new GetFileContentOperation(myFile, myEnvironment, myRevision);
CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file"), operation), CvsOperationExecutorCallback.EMPTY);
CvsResult result = executor.getResult();
if (result.isCanceled()) {
throw new ProcessCanceledException();
}
if (result.hasErrors()) {
throw result.composeError();
}
if (!operation.isLoaded()) {
throw new VcsException("Network problem");
}
myContent = operation.getFileBytes();
}
return myContent;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class CvsRootConfiguration method testConnection.
public void testConnection(Project project) throws AuthenticationException, IOException {
final IConnection connection = createSettings().createConnection(new ReadWriteStatistics());
final ErrorMessagesProcessor errorProcessor = new ErrorMessagesProcessor();
final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(errorProcessor, CvsExecutionEnvironment.DUMMY_STOPPER, errorProcessor, PostCvsActivity.DEAF, project);
final CvsResult result = new CvsResultEx();
try {
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
final GetModulesListOperation operation = new GetModulesListOperation(createSettings());
final CvsRootProvider cvsRootProvider = operation.getCvsRootProvider();
try {
if (connection instanceof SelfTestingConnection) {
((SelfTestingConnection) connection).test(CvsListenerWithProgress.createOnProgress());
}
operation.execute(cvsRootProvider, cvsExecutionEnvironment, connection, DummyProgressViewer.INSTANCE);
} catch (ValidRequestsExpectedException ex) {
result.addError(new CvsException(ex, cvsRootProvider.getCvsRootAsString()));
} catch (CommandException ex) {
result.addError(new CvsException(ex.getUnderlyingException(), cvsRootProvider.getCvsRootAsString()));
} catch (ProcessCanceledException ex) {
result.setIsCanceled();
} catch (BugLog.BugException e) {
LOG.error(e);
} catch (Exception e) {
result.addError(new CvsException(e, cvsRootProvider.getCvsRootAsString()));
}
}, CvsBundle.message("operation.name.test.connection"), true, null);
if (result.isCanceled())
throw new ProcessCanceledException();
if (result.hasErrors()) {
final VcsException vcsException = result.composeError();
throw new AuthenticationException(vcsException.getLocalizedMessage(), vcsException.getCause());
}
final List<VcsException> errors = errorProcessor.getErrors();
if (!errors.isEmpty()) {
final VcsException firstError = errors.get(0);
throw new AuthenticationException(firstError.getLocalizedMessage(), firstError);
}
} finally {
connection.close();
}
}
Aggregations