Search in sources :

Example 1 with VcsFileRevision

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

the class HgHistoryTest method testCurrentAndPreviousRevisions.

/**
   * 1. Make two versions of a file (create, add, commit, modify, commit).
   * 2. Get the revisions history.
   * 3. Verify versions' contents and the current version.
   */
@Test
public void testCurrentAndPreviousRevisions() 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++;
    final VcsHistorySession session = getHistorySession(AFILE);
    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 2 with VcsFileRevision

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

the class SvnProtocolsTest method testHistoryImpl.

private void testHistoryImpl(String s) throws VcsException {
    final VcsHistoryProvider provider = myVcs.getVcsHistoryProvider();
    final VcsAppendableHistoryPartnerAdapter partner = new VcsAppendableHistoryPartnerAdapter() {

        @Override
        public void acceptRevision(VcsFileRevision revision) {
            super.acceptRevision(revision);
            if (getSession().getRevisionList().size() > 1) {
                throw new ProcessCanceledException();
            }
        }
    };
    try {
        provider.reportAppendableHistory(VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(s, true), partner);
    } catch (ProcessCanceledException e) {
    //ok
    }
    final List<VcsFileRevision> list = partner.getSession().getRevisionList();
    Assert.assertTrue(!list.isEmpty());
}
Also used : VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) VcsAppendableHistoryPartnerAdapter(com.intellij.openapi.vcs.history.VcsAppendableHistoryPartnerAdapter) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 3 with VcsFileRevision

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

the class SvnHistoryTest method testRepositoryRootHistory.

@Test
public void testRepositoryRootHistory() 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();
    }
    final Semaphore semaphore = new Semaphore();
    semaphore.down();
    final FilePath rootPath = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(myRepoUrl, true);
    provider.reportAppendableHistory(rootPath, new VcsAppendableHistorySessionPartner() {

        @Override
        public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
        }

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

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

        @Override
        public void finished() {
        }

        @Override
        public void beforeRefresh() {
        }

        @Override
        public void forceRefresh() {
        }
    });
    semaphore.waitFor(1000);
    Assert.assertTrue(myCnt > 0);
}
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 4 with VcsFileRevision

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

the class SvnHistoryTest method testSimpleHistoryLocal.

@Test
public void testSimpleHistoryLocal() 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();
    }
    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);
}
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 5 with VcsFileRevision

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

the class SvnHistoryTest method testSimpleHistory.

@Test
public void testSimpleHistory() 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();
    }
    final Semaphore semaphore = new Semaphore();
    semaphore.down();
    final FilePath rootPath = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(myRepoUrl + "/root/source/s1.txt", true);
    provider.reportAppendableHistory(rootPath, 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);
}
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)

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