view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialMountPointsSupportTest.java @ 703:3aff8caf7d60

add API to parse hg log --patch to recover .hgsub .hgsubstate for entire history
author eugene.petrenko@jetbrains.com
date Wed, 08 Jan 2014 16:37:57 +0100
parents
children c27e501ed0c3
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial;

import jetbrains.buildServer.vcs.CheckoutRules;
import jetbrains.buildServer.vcs.VcsRoot;
import jetbrains.buildServer.vcs.impl.VcsRootImpl;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.File;

import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig;
import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;

/**
 * Created 03.01.14 14:10
 *
 * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
 */
@RequiredHgVersion(min = "1.7.0")
@Test(dataProviderClass = HgVersionConstraint.class, dataProvider = "installedHgVersion")
public class MercurialMountPointsSupportTest extends BaseMercurialTestCase {

  private File myRemoteRepository;
  private MercurialMountPointsSupport mySupport;
  private MercurialVcsSupport myVcs;
  private File myRemoteRepo1;
  private File myRemoteRepo2;
  private File myRemoteRepo3;
  private VcsRootImpl myRoot;

  @BeforeMethod
  public void setUp() throws Exception {
    super.setUp();
    ServerPluginConfig config = serverPluginConfig()
            .cachesDir(myTempFiles.createTempDir())
            .hgPath(Util.getHgPath())
            .build();

    myRemoteRepository = myTempFiles.createTempDir();
    Util.copyRepository(new File("mercurial-tests/testData/rep2"), myRemoteRepository);
    MercurialSupportBuilder hgBuilder = mercurialSupport().withConfig(config);
    MercurialVcsSupport vcs = hgBuilder.build();
    myVcs = vcs;
    mySupport = new MercurialMountPointsSupport(vcs, hgBuilder.getHgRootFactory());


    File remoteRepoParentDir = myTempFiles.createTempDir();
    myRemoteRepo1 = new File(remoteRepoParentDir, "r1");
    myRemoteRepo2 = new File(remoteRepoParentDir, "r2");
    myRemoteRepo3 = new File(remoteRepoParentDir, "r3");
    copyRepository(new File("mercurial-tests/testData/subrepos/r1"), myRemoteRepo1);
    copyRepository(new File("mercurial-tests/testData/subrepos/r2"), myRemoteRepo2);
    copyRepository(new File("mercurial-tests/testData/subrepos/r3"), myRemoteRepo3);
    ServerPluginConfig myPluginConfig = new ServerPluginConfigBuilder()
            .cachesDir(myTempFiles.createTempDir())
            .detectSubrepoChanges(true)
            .build();
    myVcs = mercurialSupport().withConfig(myPluginConfig).build();
    myRoot = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).withSubrepoChanges(true).build();
  }

  @Test(enabled = false)
  public void should_return_commits_for_every_revision_in_state_local(HgVersion _) throws Exception {
    VcsRoot root = vcsRoot().withUrl("F:\\Work\\ReSharper\\Psi.Features").build();
    myVcs.syncRepository(root);

    final long start = System.currentTimeMillis();
    mySupport.collectMountPoints(root, CheckoutRules.DEFAULT, 42);

    final long actual = System.currentTimeMillis() - start;
    System.out.println("All mount points were computed in " + actual + " ms");
  }

  public void should_return_commits_for_every_revision_in_state(HgVersion _) throws Exception {
    myVcs.syncRepository(myRoot);
    mySupport.collectMountPoints(myRoot, CheckoutRules.DEFAULT, 42);
  }

}