Search in sources :

Example 16 with ContentRevision

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

the class GitNewChangesCollector method reportAdded.

private void reportAdded(String filepath) throws VcsException {
    ContentRevision before = null;
    ContentRevision after = GitContentRevision.createRevision(myVcsRoot, filepath, null, myProject, false, false, false);
    reportChange(FileStatus.ADDED, before, after);
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) GitContentRevision(git4idea.GitContentRevision)

Example 17 with ContentRevision

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

the class GitOldChangesCollector method parseFiles.

private void parseFiles(String list) throws VcsException {
    for (StringScanner sc = new StringScanner(list); sc.hasMoreData(); ) {
        if (sc.isEol()) {
            sc.nextLine();
            continue;
        }
        char status = sc.peek();
        sc.skipChars(2);
        if ('?' == status) {
            VirtualFile file = myVcsRoot.findFileByRelativePath(GitUtil.unescapePath(sc.line()));
            if (Comparing.equal(GitUtil.gitRootOrNull(file), myVcsRoot)) {
                myUnversioned.add(file);
            }
        } else {
            //noinspection HardCodedStringLiteral
            if ('M' == status) {
                sc.boundedToken('\t');
                String file = GitUtil.unescapePath(sc.line());
                VirtualFile vFile = myVcsRoot.findFileByRelativePath(file);
                if (!Comparing.equal(GitUtil.gitRootOrNull(vFile), myVcsRoot)) {
                    continue;
                }
                if (!myUnmergedNames.add(file)) {
                    continue;
                }
                // assume modify-modify conflict
                ContentRevision before = GitContentRevision.createRevision(myVcsRoot, file, new GitRevisionNumber("orig_head"), myProject, false, true, true);
                ContentRevision after = GitContentRevision.createRevision(myVcsRoot, file, null, myProject, false, false, true);
                myChanges.add(new Change(before, after, FileStatus.MERGED_WITH_CONFLICTS));
            } else {
                throw new VcsException("Unsupported type of the merge conflict detected: " + status);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GitRevisionNumber(git4idea.GitRevisionNumber) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) GitContentRevision(git4idea.GitContentRevision) Change(com.intellij.openapi.vcs.changes.Change) StringScanner(git4idea.util.StringScanner)

Example 18 with ContentRevision

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

the class GitMergeUpdater method getLocalChangesFilteredByFiles.

private Collection<Change> getLocalChangesFilteredByFiles(List<FilePath> paths) {
    final Collection<Change> changes = new HashSet<>();
    for (LocalChangeList list : myChangeListManager.getChangeLists()) {
        for (Change change : list.getChanges()) {
            final ContentRevision afterRevision = change.getAfterRevision();
            final ContentRevision beforeRevision = change.getBeforeRevision();
            if ((afterRevision != null && paths.contains(afterRevision.getFile())) || (beforeRevision != null && paths.contains(beforeRevision.getFile()))) {
                changes.add(change);
            }
        }
    }
    return changes;
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change)

Example 19 with ContentRevision

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

the class TestDiscoverySearchHelper method getAffectedFiles.

@NotNull
private static List<VirtualFile> getAffectedFiles(String changeListName, Project project) {
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    if ("All".equals(changeListName)) {
        return changeListManager.getAffectedFiles();
    }
    final LocalChangeList changeList = changeListManager.findChangeList(changeListName);
    if (changeList != null) {
        List<VirtualFile> files = new ArrayList<>();
        for (Change change : changeList.getChanges()) {
            final ContentRevision afterRevision = change.getAfterRevision();
            if (afterRevision != null) {
                final VirtualFile file = afterRevision.getFile().getVirtualFile();
                if (file != null) {
                    files.add(file);
                }
            }
        }
        return files;
    }
    return Collections.emptyList();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with ContentRevision

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

the class BaseAnalysisActionDialog method getScope.

@NotNull
public AnalysisScope getScope(@NotNull AnalysisUIOptions uiOptions, @NotNull AnalysisScope defaultScope, @NotNull Project project, Module module) {
    AnalysisScope scope;
    if (isProjectScopeSelected()) {
        scope = new AnalysisScope(project);
        uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT;
    } else {
        final SearchScope customScope = getCustomScope();
        if (customScope != null) {
            scope = new AnalysisScope(customScope, project);
            uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM;
            uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName();
        } else if (isModuleScopeSelected()) {
            scope = new AnalysisScope(module);
            uiOptions.SCOPE_TYPE = AnalysisScope.MODULE;
        } else if (isUncommitedFilesSelected()) {
            final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
            List<VirtualFile> files;
            if (myChangeLists.getSelectedItem() == ALL) {
                files = changeListManager.getAffectedFiles();
            } else {
                files = new ArrayList<>();
                for (ChangeList list : changeListManager.getChangeListsCopy()) {
                    if (!Comparing.strEqual(list.getName(), (String) myChangeLists.getSelectedItem()))
                        continue;
                    final Collection<Change> changes = list.getChanges();
                    for (Change change : changes) {
                        final ContentRevision afterRevision = change.getAfterRevision();
                        if (afterRevision != null) {
                            final VirtualFile vFile = afterRevision.getFile().getVirtualFile();
                            if (vFile != null) {
                                files.add(vFile);
                            }
                        }
                    }
                }
            }
            scope = new AnalysisScope(project, new HashSet<>(files));
            uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES;
        } else {
            scope = defaultScope;
            //just not project scope
            uiOptions.SCOPE_TYPE = defaultScope.getScopeType();
        }
    }
    uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources();
    scope.setIncludeTestSource(isInspectTestSources());
    FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName());
    return scope;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) SearchScope(com.intellij.psi.search.SearchScope) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)53 Change (com.intellij.openapi.vcs.changes.Change)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)18 FilePath (com.intellij.openapi.vcs.FilePath)15 NotNull (org.jetbrains.annotations.NotNull)12 VcsException (com.intellij.openapi.vcs.VcsException)9 GitContentRevision (git4idea.GitContentRevision)9 File (java.io.File)9 FileStatus (com.intellij.openapi.vcs.FileStatus)5 Nullable (org.jetbrains.annotations.Nullable)5 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)4 CurrentContentRevision (com.intellij.openapi.vcs.changes.CurrentContentRevision)4 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 GitRevisionNumber (git4idea.GitRevisionNumber)3 AccessToken (com.intellij.openapi.application.AccessToken)2 Project (com.intellij.openapi.project.Project)2 Ref (com.intellij.openapi.util.Ref)2 BinaryContentRevision (com.intellij.openapi.vcs.changes.BinaryContentRevision)2 ByteBackedContentRevision (com.intellij.openapi.vcs.changes.ByteBackedContentRevision)2 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2