Search in sources :

Example 11 with CommittedChangeList

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

the class AbstractVcsHelperImpl method getRemoteList.

@Nullable
public static CommittedChangeList getRemoteList(@NotNull AbstractVcs vcs, @NotNull VcsRevisionNumber revision, @NotNull VirtualFile nonLocal) throws VcsException {
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    final RepositoryLocation local = provider.getForNonLocal(nonLocal);
    if (local != null) {
        final String number = revision.asString();
        final ChangeBrowserSettings settings = provider.createDefaultSettings();
        final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
        if (changes != null) {
            for (CommittedChangeList change : changes) {
                if (number.equals(String.valueOf(change.getNumber()))) {
                    return change;
                }
            }
        }
    }
    return null;
}
Also used : ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with CommittedChangeList

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

the class AbstractVcsHelperImpl method loadAndShowCommittedChangesDetails.

@Override
public void loadAndShowCommittedChangesDetails(@NotNull final Project project, @NotNull final VcsRevisionNumber revision, @NotNull final VirtualFile virtualFile, @NotNull VcsKey vcsKey, @Nullable final RepositoryLocation location, final boolean isNonLocal) {
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
    if (vcs == null)
        return;
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider == null)
        return;
    if (isNonLocal && provider.getForNonLocal(virtualFile) == null)
        return;
    final String title = VcsBundle.message("paths.affected.in.revision", revision instanceof ShortVcsRevisionNumber ? ((ShortVcsRevisionNumber) revision).toShortString() : revision.asString());
    final CommittedChangeList[] list = new CommittedChangeList[1];
    final FilePath[] targetPath = new FilePath[1];
    final VcsException[] exc = new VcsException[1];
    final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS, revision, virtualFile.getPath());
    if (lock.isLocked())
        return;
    lock.lock();
    Task.Backgroundable task = new Task.Backgroundable(project, title, true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {
                if (!isNonLocal) {
                    final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
                    if (pair != null) {
                        list[0] = pair.getFirst();
                        targetPath[0] = pair.getSecond();
                    }
                } else {
                    if (location != null) {
                        final ChangeBrowserSettings settings = provider.createDefaultSettings();
                        settings.USE_CHANGE_BEFORE_FILTER = true;
                        settings.CHANGE_BEFORE = revision.asString();
                        final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
                        if (changes != null && changes.size() == 1) {
                            list[0] = changes.get(0);
                        }
                    } else {
                        list[0] = getRemoteList(vcs, revision, virtualFile);
                    }
                }
            } catch (VcsException e) {
                exc[0] = e;
            }
        }

        @Override
        public void onCancel() {
            lock.unlock();
        }

        @Override
        public void onSuccess() {
            lock.unlock();
            if (exc[0] != null) {
                showError(exc[0], failedText(virtualFile, revision));
            } else if (list[0] == null) {
                Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
            } else {
                VirtualFile navigateToFile = targetPath[0] != null ? new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) : virtualFile;
                showChangesListBrowser(list[0], navigateToFile, title);
            }
        }
    };
    // we can's use runProcessWithProgressAsynchronously(task) because then ModalityState.NON_MODAL would be used
    CoreProgressManager progressManager = (CoreProgressManager) ProgressManager.getInstance();
    progressManager.runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task), null, ModalityState.current());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) Task(com.intellij.openapi.progress.Task) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) NotNull(org.jetbrains.annotations.NotNull) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)

Example 13 with CommittedChangeList

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

the class UpdateInfoTree method createCenterPanel.

protected JComponent createCenterPanel() {
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
    myCenterPanel.add(CARD_STATUS, scrollPane);
    myTreeBrowser = new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList());
    Disposer.register(this, myTreeBrowser);
    myTreeBrowser.setHelpId(getHelpId());
    myCenterPanel.add(CARD_CHANGES, myTreeBrowser);
    return myCenterPanel;
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) CommittedChangesTreeBrowser(com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser)

Example 14 with CommittedChangeList

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

the class CommittedChangesBrowser method updateBySelectionChange.

private void updateBySelectionChange() {
    final int idx = myChangeListsView.getSelectionModel().getLeadSelectionIndex();
    final List<CommittedChangeList> items = myTableModel.getItems();
    CommittedChangeList list = (idx >= 0 && idx < items.size()) ? items.get(idx) : null;
    if (list != mySelectedChangeList) {
        mySelectedChangeList = list;
        myChangesView.setChangesToDisplay(list != null ? new ArrayList<>(list.getChanges()) : Collections.<Change>emptyList());
        myCommitMessageArea.setText(list != null ? formatText(list) : "");
        myCommitMessageArea.select(0, 0);
    }
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change)

Example 15 with CommittedChangeList

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

the class CommittedChangesCache method initCache.

private List<CommittedChangeList> initCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
    debug("Initializing cache for " + cacheFile.getLocation());
    final CachingCommittedChangesProvider provider = cacheFile.getProvider();
    final RepositoryLocation location = cacheFile.getLocation();
    final ChangeBrowserSettings settings = provider.createDefaultSettings();
    int maxCount = 0;
    if (isMaxCountSupportedForProject()) {
        maxCount = myState.getInitialCount();
    } else {
        settings.USE_DATE_AFTER_FILTER = true;
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, -myState.getInitialDays());
        settings.setDateAfter(calendar.getTime());
    }
    //noinspection unchecked
    final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, maxCount);
    // when initially initializing cache, assume all changelists are locally available
    // this sorts changes in chronological order
    writeChangesInReadAction(cacheFile, changes);
    if (maxCount > 0 && changes.size() < myState.getInitialCount()) {
        cacheFile.setHaveCompleteHistory(true);
    }
    if (changes.size() > 0) {
        fireChangesLoaded(location, changes);
    }
    return changes;
}
Also used : ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Aggregations

CommittedChangeList (com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)45 ChangeBrowserSettings (com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings)8 Nullable (org.jetbrains.annotations.Nullable)8 Change (com.intellij.openapi.vcs.changes.Change)7 ChangesBunch (com.intellij.openapi.vcs.changes.committed.ChangesBunch)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)4 NotNull (org.jetbrains.annotations.NotNull)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Project (com.intellij.openapi.project.Project)3 Pair (com.intellij.openapi.util.Pair)3 List (java.util.List)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Application (com.intellij.openapi.application.Application)2 Task (com.intellij.openapi.progress.Task)2 Ref (com.intellij.openapi.util.Ref)2 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)2 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)2 ChangesBrowserSettingsEditor (com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor)2 IOException (java.io.IOException)2