Search in sources :

Example 56 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class CopiesPanel method getSupportedFormats.

@NotNull
private List<WorkingCopyFormat> getSupportedFormats() {
    List<WorkingCopyFormat> result = ContainerUtil.newArrayList();
    ClientFactory factory = myVcs.getFactory();
    ClientFactory otherFactory = myVcs.getOtherFactory(factory);
    try {
        result.addAll(factory.createUpgradeClient().getSupportedFormats());
        result.addAll(SvnFormatWorker.getOtherFactoryFormats(otherFactory));
    } catch (VcsException e) {
        LOG.info(e);
    }
    return result;
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 57 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class SetPropertyDialog method fillPropertyNames.

private void fillPropertyNames(File[] files) {
    final Collection<String> names = new TreeSet<>();
    if (files.length == 1) {
        File file = files[0];
        try {
            PropertyConsumer handler = new PropertyConsumer() {

                public void handleProperty(File path, PropertyData property) {
                    String name = property.getName();
                    if (name != null) {
                        names.add(name);
                    }
                }

                public void handleProperty(SVNURL url, PropertyData property) {
                }

                public void handleProperty(long revision, PropertyData property) {
                }
            };
            PropertyClient client = myVCS.getFactory(file).createPropertyClient();
            client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, Depth.EMPTY, handler);
        } catch (VcsException e) {
            LOG.info(e);
        }
    }
    fillProperties(names);
    for (final String name : names) {
        myPropertyNameBox.addItem(name);
    }
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) TreeSet(java.util.TreeSet) SVNURL(org.tmatesoft.svn.core.SVNURL) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 58 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class SetPropertyDialog method getProperty.

@Nullable
private PropertyValue getProperty(@NotNull File file, @NotNull String name) {
    PropertyValue result;
    try {
        PropertyClient client = myVCS.getFactory(file).createPropertyClient();
        result = client.getProperty(SvnTarget.fromFile(file, SVNRevision.WORKING), name, false, SVNRevision.WORKING);
    } catch (VcsException e) {
        LOG.info(e);
        result = null;
    }
    return result;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) Nullable(org.jetbrains.annotations.Nullable)

Example 59 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class AnnotateRevisionActionBase method annotate.

public static void annotate(@NotNull VirtualFile file, @NotNull VcsFileRevision fileRevision, @NotNull AbstractVcs vcs, @Nullable Editor editor, int annotatedLine) {
    final CharSequence oldContent = editor == null ? null : editor.getDocument().getImmutableCharSequence();
    final AnnotationProvider annotationProvider = vcs.getAnnotationProvider();
    assert annotationProvider != null;
    final Ref<FileAnnotation> fileAnnotationRef = new Ref<>();
    final Ref<Integer> newLineRef = new Ref<>();
    final Ref<VcsException> exceptionRef = new Ref<>();
    VcsAnnotateUtil.getBackgroundableLock(vcs.getProject(), file).lock();
    Semaphore semaphore = new Semaphore(0);
    AtomicBoolean shouldOpenEditorInSync = new AtomicBoolean(true);
    ProgressManager.getInstance().run(new Task.Backgroundable(vcs.getProject(), VcsBundle.message("retrieving.annotations"), true) {

        public void run(@NotNull ProgressIndicator indicator) {
            try {
                FileAnnotation fileAnnotation = annotationProvider.annotate(file, fileRevision);
                int newLine = translateLine(oldContent, fileAnnotation.getAnnotatedContent(), annotatedLine);
                fileAnnotationRef.set(fileAnnotation);
                newLineRef.set(newLine);
                shouldOpenEditorInSync.set(false);
                semaphore.release();
            } catch (VcsException e) {
                exceptionRef.set(e);
            }
        }

        @Override
        public void onFinished() {
            VcsAnnotateUtil.getBackgroundableLock(vcs.getProject(), file).unlock();
        }

        @Override
        public void onSuccess() {
            if (!exceptionRef.isNull()) {
                AbstractVcsHelper.getInstance(myProject).showError(exceptionRef.get(), VcsBundle.message("operation.name.annotate"));
            }
            if (fileAnnotationRef.isNull())
                return;
            AbstractVcsHelper.getInstance(myProject).showAnnotation(fileAnnotationRef.get(), file, vcs, newLineRef.get());
        }
    });
    try {
        semaphore.tryAcquire(ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS, TimeUnit.MILLISECONDS);
        // This will remove blinking on editor opening (step 1 - editor opens, step 2 - annotations are shown).
        if (shouldOpenEditorInSync.get()) {
            CharSequence content = LoadTextUtil.loadText(file);
            int newLine = translateLine(oldContent, content, annotatedLine);
            OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(vcs.getProject(), file, newLine, 0);
            FileEditorManager.getInstance(vcs.getProject()).openTextEditor(openFileDescriptor, true);
        }
    } catch (InterruptedException ignore) {
    }
}
Also used : Task(com.intellij.openapi.progress.Task) AnnotationProvider(com.intellij.openapi.vcs.annotate.AnnotationProvider) Semaphore(java.util.concurrent.Semaphore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation)

Example 60 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class VcsAnnotationCachedProxy method annotate.

@Override
public FileAnnotation annotate(final VirtualFile file) throws VcsException {
    final DiffProvider diffProvider = myVcs.getDiffProvider();
    final VcsRevisionNumber currentRevision = diffProvider.getCurrentRevision(file);
    return annotate(file, currentRevision, true, new ThrowableComputable<FileAnnotation, VcsException>() {

        @Override
        public FileAnnotation compute() throws VcsException {
            return myAnnotationProvider.annotate(file);
        }
    });
}
Also used : DiffProvider(com.intellij.openapi.vcs.diff.DiffProvider) VcsException(com.intellij.openapi.vcs.VcsException) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation)

Aggregations

VcsException (com.intellij.openapi.vcs.VcsException)200 VirtualFile (com.intellij.openapi.vfs.VirtualFile)89 File (java.io.File)48 NotNull (org.jetbrains.annotations.NotNull)42 FilePath (com.intellij.openapi.vcs.FilePath)35 Change (com.intellij.openapi.vcs.changes.Change)33 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)26 ArrayList (java.util.ArrayList)24 Nullable (org.jetbrains.annotations.Nullable)23 IOException (java.io.IOException)20 SVNException (org.tmatesoft.svn.core.SVNException)19 Project (com.intellij.openapi.project.Project)17 Ref (com.intellij.openapi.util.Ref)16 Test (org.junit.Test)14 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)13 GitRepository (git4idea.repo.GitRepository)12 Task (com.intellij.openapi.progress.Task)11 List (java.util.List)11 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)10 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)10