Search in sources :

Example 16 with CommittedChangeList

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

the class CommittedChangesCache method refreshCache.

// todo: fix - would externally loaded necessarily for file? i.e. just not efficient now
private List<CommittedChangeList> refreshCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
    final List<CommittedChangeList> newLists = new ArrayList<>();
    final CachingCommittedChangesProvider provider = cacheFile.getProvider();
    final RepositoryLocation location = cacheFile.getLocation();
    final Pair<Long, List<CommittedChangeList>> externalLists = myExternallyLoadedChangeLists.get(location.getKey());
    final long latestChangeList = getLatestListForFile(cacheFile);
    if ((externalLists != null) && (latestChangeList == externalLists.first.longValue())) {
        newLists.addAll(appendLoadedChanges(cacheFile, location, externalLists.second));
        myExternallyLoadedChangeLists.clear();
    }
    final ChangeBrowserSettings defaultSettings = provider.createDefaultSettings();
    int maxCount = 0;
    if (provider.refreshCacheByNumber()) {
        final long number = cacheFile.getLastCachedChangelist();
        debug("Refreshing cache for " + location + " since #" + number);
        if (number >= 0) {
            defaultSettings.CHANGE_AFTER = Long.toString(number);
            defaultSettings.USE_CHANGE_AFTER_FILTER = true;
        } else {
            maxCount = myState.getInitialCount();
        }
    } else {
        final Date date = cacheFile.getLastCachedDate();
        debug("Refreshing cache for " + location + " since " + date);
        defaultSettings.setDateAfter(date);
        defaultSettings.USE_DATE_AFTER_FILTER = true;
    }
    defaultSettings.STRICTLY_AFTER = true;
    final List<CommittedChangeList> newChanges = provider.getCommittedChanges(defaultSettings, location, maxCount);
    debug("Loaded " + newChanges.size() + " new changelists");
    newLists.addAll(appendLoadedChanges(cacheFile, location, newChanges));
    return newLists;
}
Also used : ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Example 17 with CommittedChangeList

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

the class CommittedChangesTreeBrowser method buildTreeModel.

private TreeModel buildTreeModel(final List<CommittedChangeList> filteredChangeLists) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    DefaultTreeModel model = new DefaultTreeModel(root);
    Collections.sort(filteredChangeLists, myGroupingStrategy.getComparator());
    myGroupingStrategy.beforeStart();
    DefaultMutableTreeNode lastGroupNode = null;
    String lastGroupName = null;
    for (CommittedChangeList list : filteredChangeLists) {
        String groupName = StringUtil.notNullize(myGroupingStrategy.getGroupName(list));
        if (!Comparing.equal(groupName, lastGroupName)) {
            lastGroupName = groupName;
            lastGroupNode = new DefaultMutableTreeNode(lastGroupName);
            root.add(lastGroupNode);
        }
        assert lastGroupNode != null;
        lastGroupNode.add(new DefaultMutableTreeNode(list));
    }
    return model;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 18 with CommittedChangeList

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

the class CommittedChangesTreeBrowser method collectChanges.

@NotNull
public static List<Change> collectChanges(final List<? extends CommittedChangeList> selectedChangeLists, final boolean withMovedTrees) {
    Collections.sort(selectedChangeLists, CommittedChangeListByDateComparator.ASCENDING);
    List<Change> changes = new ArrayList<>();
    for (CommittedChangeList cl : selectedChangeLists) {
        changes.addAll(withMovedTrees ? cl.getChangesWithMovedTrees() : cl.getChanges());
    }
    return zipChanges(changes);
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with CommittedChangeList

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

the class CommittedChangesTreeBrowser method updateBySelectionChange.

private void updateBySelectionChange() {
    List<CommittedChangeList> selection = new ArrayList<>();
    final TreePath[] selectionPaths = myChangesTree.getSelectionPaths();
    if (selectionPaths != null) {
        for (TreePath path : selectionPaths) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            if (node.getUserObject() instanceof CommittedChangeList) {
                selection.add((CommittedChangeList) node.getUserObject());
            }
        }
    }
    if (!selection.equals(mySelectedChangeLists)) {
        mySelectedChangeLists = selection;
        myDetailsView.setChangesToDisplay(collectChanges(mySelectedChangeLists, false));
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Example 20 with CommittedChangeList

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

the class CommittedListsSequencesZipper method mergeLocationGroupChangeLists.

@NotNull
private List<CommittedChangeList> mergeLocationGroupChangeLists(@NotNull RepositoryLocationGroup group) {
    List<CommittedChangeList> result = ContainerUtil.newArrayList();
    List<CommittedChangeList> equalLists = ContainerUtil.newArrayList();
    CommittedChangeList previousList = null;
    for (CommittedChangeList list : Iterables.mergeSorted(collectChangeLists(group.getLocations()), myComparator)) {
        if (previousList != null && myComparator.compare(previousList, list) != 0) {
            result.add(zip(group, equalLists));
            equalLists.clear();
        }
        equalLists.add(list);
        previousList = list;
    }
    if (!equalLists.isEmpty()) {
        result.add(zip(group, equalLists));
    }
    return result;
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) NotNull(org.jetbrains.annotations.NotNull)

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