Search in sources :

Example 51 with ContentRevision

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

the class ChangesChecker method gather.

public void gather(final List<Change> changes) {
    final TreeMap<String, File> renames = new TreeMap<>();
    final Set<String> alsoReverted = new HashSet<>();
    final Map<String, FilePath> files = new HashMap<>();
    for (Change change : changes) {
        final ContentRevision beforeRevision = change.getBeforeRevision();
        final ContentRevision afterRevision = change.getAfterRevision();
        final String key = afterRevision == null ? null : FilePathsHelper.convertWithLastSeparator(afterRevision.getFile());
        if (SvnRollbackEnvironment.isMoveRenameReplace(change)) {
            final File beforeFile = beforeRevision.getFile().getIOFile();
            renames.put(key, beforeFile);
            files.put(key, afterRevision.getFile());
            myCollector.markRename(beforeFile, afterRevision.getFile().getIOFile());
        } else if (afterRevision != null) {
            alsoReverted.add(key);
        }
    }
    if (!renames.isEmpty()) {
        final ArrayList<String> paths = new ArrayList<>(renames.keySet());
        if (paths.size() > 1) {
            FilterFilePathStrings.getInstance().doFilter(paths);
        }
        myCollector.setRenamesMap(renames);
        myCollector.setAlsoReverted(alsoReverted);
        for (String path : paths) {
            try {
                myChangeProvider.getChanges(files.get(path), true, myCollector);
            } catch (SVNException e) {
                myExceptions.add(new VcsException(e));
            } catch (SvnBindException e) {
                myExceptions.add(e);
            }
        }
    }
    for (Change change : changes) {
        final ContentRevision afterRevision = change.getAfterRevision();
        boolean checked = myForAdds.accept(change);
        checked |= myForDeletes.accept(change);
        if (!checked) {
            myForEdits.add(afterRevision.getFile().getIOFile());
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) SVNException(org.tmatesoft.svn.core.SVNException) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 52 with ContentRevision

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

the class HgDiffProviderTest method shouldFindCurrentRevisionForRenamedFile.

@Test
public void shouldFindCurrentRevisionForRenamedFile() throws Exception {
    fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
    addAll();
    commitAll("initial content");
    fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
    commitAll("updated content");
    runHgOnProjectRepo("rename", AFILE, BFILE);
    //don't commit 
    refreshVfs();
    ChangeListManager.getInstance(myProject).ensureUpToDate(false);
    HgDiffProvider diffProvider = new HgDiffProvider(myProject);
    VirtualFile child = myWorkingCopyDir.findChild(BFILE);
    ContentRevision fileContent = diffProvider.createFileContent(diffProvider.getCurrentRevision(child), child);
    assertNotNull(fileContent);
    assertEquals(fileContent.getContent(), UPDATED_FILE_CONTENT);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) HgDiffProvider(org.zmlx.hg4idea.provider.HgDiffProvider) Test(org.testng.annotations.Test)

Example 53 with ContentRevision

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

the class SvnCommittedViewTest method printChanges.

private static String printChanges(final Data data, final Collection<Change> changes) {
    final StringBuilder sb = new StringBuilder("Data: ").append(data.myLocalPath).append(" exists: ").append(new File(data.myLocalPath).exists()).append(" Changes: ");
    for (Change change : changes) {
        final ContentRevision cr = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
        final File ioFile = cr.getFile().getIOFile();
        sb.append("'").append(ioFile.getAbsolutePath()).append("' exists: ").append(ioFile.exists()).append(" | ");
    }
    return sb.toString();
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)

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