use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class VcsVirtualFile method loadContent.
private void loadContent() throws IOException {
if (myContent != null)
return;
assert myFileRevision != null;
final VcsFileSystem vcsFileSystem = ((VcsFileSystem) getFileSystem());
try {
myFileRevision.loadContent();
fireBeforeContentsChange();
myModificationStamp++;
final VcsRevisionNumber revisionNumber = myFileRevision.getRevisionNumber();
if (revisionNumber instanceof ShortVcsRevisionNumber) {
setRevision(((ShortVcsRevisionNumber) revisionNumber).toShortString());
} else {
setRevision(revisionNumber.asString());
}
myContent = myFileRevision.getContent();
myCharset = new CharsetToolkit(myContent).guessEncoding(myContent.length);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireContentsChanged(this, VcsVirtualFile.this, 0);
}
});
} catch (VcsException e) {
myContentLoadFailed = true;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireBeforeFileDeletion(this, VcsVirtualFile.this);
}
});
myContent = ArrayUtil.EMPTY_BYTE_ARRAY;
setRevision("0");
Messages.showMessageDialog(VcsBundle.message("message.text.could.not.load.virtual.file.content", getPresentableUrl(), e.getLocalizedMessage()), VcsBundle.message("message.title.could.not.load.content"), Messages.getInformationIcon());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireFileDeleted(this, VcsVirtualFile.this, getName(), getParent());
}
});
} catch (ProcessCanceledException ex) {
myContent = null;
}
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class ActionWithTempFile method execute.
public void execute() throws VcsException {
try {
try {
init();
executeInternal();
} finally {
rollbackChanges();
}
} catch (IOException e) {
throw new VcsException(e);
}
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SelectFilesToAddTextsToPatchPanel method getBig.
public static Set<Change> getBig(List<Change> changes) {
final Set<Change> exclude = new HashSet<>();
for (Change change : changes) {
// try to estimate size via VF: we assume that base content hasn't been changed much
VirtualFile virtualFile = getVfFromChange(change);
if (virtualFile != null) {
if (isBig(virtualFile)) {
exclude.add(change);
}
continue;
}
// otherwise, to avoid regression we have to process context length
ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null) {
try {
String content = beforeRevision.getContent();
if (content == null) {
final FilePath file = beforeRevision.getFile();
LOG.info("null content for " + (file.getPath()) + ", is dir: " + (file.isDirectory()));
continue;
}
if (content.length() > VcsConfiguration.ourMaximumFileForBaseRevisionSize) {
exclude.add(change);
}
} catch (VcsException e) {
LOG.info(e);
}
}
}
return exclude;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class ImportIntoShelfAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return;
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true);
FileChooser.chooseFiles(descriptor, project, null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(final List<VirtualFile> files) {
//gatherPatchFiles
final ProgressManager pm = ProgressManager.getInstance();
final ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(project);
final List<VirtualFile> patchTypeFiles = new ArrayList<>();
final boolean filesFound = pm.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
patchTypeFiles.addAll(shelveChangesManager.gatherPatchFiles(files));
}
}, "Looking for patch files...", true, project);
if (!filesFound || patchTypeFiles.isEmpty())
return;
if (!patchTypeFiles.equals(files)) {
final String message = "Found " + (patchTypeFiles.size() == 1 ? "one patch file (" + patchTypeFiles.get(0).getPath() + ")." : (patchTypeFiles.size() + " patch files.")) + "\nContinue with import?";
final int toImport = Messages.showYesNoDialog(project, message, "Import Patches", Messages.getQuestionIcon());
if (Messages.NO == toImport)
return;
}
pm.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
final List<VcsException> exceptions = new ArrayList<>();
final List<ShelvedChangeList> lists = shelveChangesManager.importChangeLists(patchTypeFiles, new Consumer<VcsException>() {
@Override
public void consume(VcsException e) {
exceptions.add(e);
}
});
if (!lists.isEmpty()) {
ShelvedChangesViewManager.getInstance(project).activateView(lists.get(lists.size() - 1));
}
if (!exceptions.isEmpty()) {
AbstractVcsHelper.getInstance(project).showErrors(exceptions, "Import patches into shelf");
}
if (lists.isEmpty() && exceptions.isEmpty()) {
VcsBalloonProblemNotifier.showOverChangesView(project, "No patches found", MessageType.WARNING);
}
}
}, "Import patches into shelf", true, project);
}
});
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class VcsHistoryUtil method loadRevisionContent.
@NotNull
public static byte[] loadRevisionContent(@NotNull VcsFileRevision revision) throws VcsException, IOException {
byte[] content = revision.getContent();
if (content == null) {
revision.loadContent();
content = revision.getContent();
}
if (content == null)
throw new VcsException("Failed to load content for revision " + revision.getRevisionNumber().asString());
return content;
}
Aggregations