Search in sources :

Example 31 with VcsFileRevision

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

the class ShowAllAffectedGenericAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null)
        return;
    final VcsKey vcsKey = e.getData(VcsDataKeys.VCS);
    if (vcsKey == null)
        return;
    final VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
    VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
    final Boolean isNonLocal = e.getData(VcsDataKeys.VCS_NON_LOCAL_HISTORY_SESSION);
    if ((revision != null) && (revisionVirtualFile != null)) {
        showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey, revision.getChangedRepositoryPath(), Boolean.TRUE.equals(isNonLocal));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 32 with VcsFileRevision

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

the class HgHistoryTest method locallyRenamedFileShouldGetHistory.

@Test
public void locallyRenamedFileShouldGetHistory() throws Exception {
    int versions = 0;
    fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
    addAll();
    commitAll("initial content");
    versions++;
    fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
    commitAll("updated content");
    versions++;
    runHgOnProjectRepo("rename", AFILE, BFILE);
    //don't commit 
    refreshVfs();
    ChangeListManager.getInstance(myProject).ensureUpToDate(false);
    final VcsHistorySession session = getHistorySession(BFILE);
    final List<VcsFileRevision> revisions = session.getRevisionList();
    for (VcsFileRevision rev : revisions) {
        rev.loadContent();
    }
    assertEquals(revisions.size(), versions);
    assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
    assertEquals(revisions.get(0).getContent(), UPDATED_FILE_CONTENT.getBytes());
    assertEquals(revisions.get(1).getContent(), INITIAL_FILE_CONTENT.getBytes());
}
Also used : VcsHistorySession(com.intellij.openapi.vcs.history.VcsHistorySession) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Test(org.testng.annotations.Test)

Example 33 with VcsFileRevision

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

the class HgHistoryTest method renameShouldPreserveFileHistory.

/**
   * 1. Make initial version of a file (create, add, commit).
   * 2. Rename file (rename, commit).
   * 3. Update file (modify, commit).
   * 4. Get the file history.
   * 5. Verify revision contents and the current revision.
   */
@Test
public void renameShouldPreserveFileHistory() throws Exception {
    int versions = 0;
    fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
    addAll();
    commitAll("initial content");
    versions++;
    runHgOnProjectRepo("rename", AFILE, BFILE);
    commitAll("file renamed");
    versions++;
    fillFile(myProjectDir, new String[] { BFILE }, UPDATED_FILE_CONTENT);
    commitAll("updated content");
    versions++;
    final VcsHistorySession session = getHistorySession(BFILE);
    final List<VcsFileRevision> revisions = session.getRevisionList();
    loadAllRevisions(revisions);
    assertEquals(revisions.size(), versions);
    assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
    assertEquals(revisions.get(0).getContent(), UPDATED_FILE_CONTENT.getBytes());
    assertEquals(revisions.get(2).getContent(), INITIAL_FILE_CONTENT.getBytes());
}
Also used : VcsHistorySession(com.intellij.openapi.vcs.history.VcsHistorySession) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Test(org.testng.annotations.Test)

Example 34 with VcsFileRevision

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

the class SvnHistoryTest method testLocallyMovedToRenamedDirectory.

@Test
public void testLocallyMovedToRenamedDirectory() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
    myCnt = 0;
    final VcsHistoryProvider provider = SvnVcs.getInstance(myProject).getVcsHistoryProvider();
    final SubTree tree = new SubTree(myWorkingCopyDir);
    checkin();
    for (int i = 0; i < 10; i++) {
        VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n" + i);
        checkin();
    }
    VcsTestUtil.renameFileInCommand(myProject, tree.myTargetDir, "renamedTarget");
    VcsTestUtil.moveFileInCommand(myProject, tree.myS1File, tree.myTargetDir);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    ChangeListManager.getInstance(myProject).ensureUpToDate(false);
    final Semaphore semaphore = new Semaphore();
    semaphore.down();
    provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myS1File), new VcsAppendableHistorySessionPartner() {

        @Override
        public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
        }

        @Override
        public void acceptRevision(VcsFileRevision revision) {
            ++myCnt;
        }

        @Override
        public void reportException(VcsException exception) {
            throw new RuntimeException(exception);
        }

        @Override
        public void finished() {
            semaphore.up();
        }

        @Override
        public void beforeRefresh() {
        }

        @Override
        public void forceRefresh() {
        }
    });
    semaphore.waitFor(1000);
    Assert.assertEquals(11, myCnt);
    myCnt = 0;
    semaphore.down();
    provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myTargetDir), new VcsAppendableHistorySessionPartner() {

        @Override
        public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
        }

        @Override
        public void acceptRevision(VcsFileRevision revision) {
            ++myCnt;
        }

        @Override
        public void reportException(VcsException exception) {
            throw new RuntimeException(exception);
        }

        @Override
        public void finished() {
            semaphore.up();
        }

        @Override
        public void beforeRefresh() {
        }

        @Override
        public void forceRefresh() {
        }
    });
    semaphore.waitFor(1000);
    Assert.assertEquals(1, myCnt);
    myCnt = 0;
    semaphore.down();
    provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myTargetFiles.get(0)), new VcsAppendableHistorySessionPartner() {

        @Override
        public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
        }

        @Override
        public void acceptRevision(VcsFileRevision revision) {
            ++myCnt;
        }

        @Override
        public void reportException(VcsException exception) {
            throw new RuntimeException(exception);
        }

        @Override
        public void finished() {
            semaphore.up();
        }

        @Override
        public void beforeRefresh() {
        }

        @Override
        public void forceRefresh() {
        }
    });
    semaphore.waitFor(1000);
    Assert.assertEquals(1, myCnt);
}
Also used : VcsAppendableHistorySessionPartner(com.intellij.openapi.vcs.history.VcsAppendableHistorySessionPartner) VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) Semaphore(com.intellij.util.concurrency.Semaphore) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VcsAbstractHistorySession(com.intellij.openapi.vcs.history.VcsAbstractHistorySession) Test(org.junit.Test)

Example 35 with VcsFileRevision

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

the class GitAnnotationProvider method loadFileHistoryInBackground.

private void loadFileHistoryInBackground(@NotNull GitFileAnnotation fileAnnotation) {
    List<VcsFileRevision> fileRevisions = BackgroundTaskUtil.computeInBackgroundAndTryWait(() -> {
        try {
            VirtualFile file = fileAnnotation.getFile();
            FilePath filePath = VcsUtil.getFilePath(file);
            VcsRevisionNumber currentRevision = fileAnnotation.getCurrentRevision();
            if (file.isInLocalFileSystem() || currentRevision == null) {
                return loadFileHistory(filePath);
            } else {
                return GitHistoryUtils.history(myProject, filePath, null, currentRevision);
            }
        } catch (VcsException e) {
            LOG.error(e);
            return null;
        }
    }, (revisions) -> {
        if (revisions == null)
            return;
        ApplicationManager.getApplication().invokeLater(() -> {
            GitFileAnnotation newFileAnnotation = new GitFileAnnotation(fileAnnotation);
            newFileAnnotation.setRevisions(revisions);
            fileAnnotation.reload(newFileAnnotation);
        }, myProject.getDisposed());
    }, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
    if (fileRevisions != null) {
        fileAnnotation.setRevisions(fileRevisions);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) VcsException(com.intellij.openapi.vcs.VcsException) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Aggregations

VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 Nullable (org.jetbrains.annotations.Nullable)13 FilePath (com.intellij.openapi.vcs.FilePath)12 Project (com.intellij.openapi.project.Project)10 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)8 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)7 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)7 VcsKey (com.intellij.openapi.vcs.VcsKey)5 VcsAbstractHistorySession (com.intellij.openapi.vcs.history.VcsAbstractHistorySession)5 VcsAppendableHistorySessionPartner (com.intellij.openapi.vcs.history.VcsAppendableHistorySessionPartner)5 Semaphore (com.intellij.util.concurrency.Semaphore)5 GitFileRevision (git4idea.GitFileRevision)5 Test (org.junit.Test)5 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)4 NotNull (org.jetbrains.annotations.NotNull)4 Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)3 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)3 HashMap (com.intellij.util.containers.HashMap)3