Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CollectChangesContextTest.java @ 1069:26edd3fdaf8a release-92234
TW-70693
(grafted from 2d8aab94494f39f647e2b56ba9f905d0f70a4f54)
author | victory.bedrosova |
---|---|
date | Thu, 18 Mar 2021 18:30:34 +0100 |
parents | 10dc26b32c35 |
children |
line wrap: on
line source
/* * Copyright 2000-2018 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.util.TestFor; import jetbrains.buildServer.vcs.RepositoryStateData; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import org.jetbrains.annotations.NotNull; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import java.util.Collection; 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.VcsRootBuilder.vcsRoot; import static jetbrains.buildServer.util.Util.map; import static junit.framework.Assert.assertTrue; @RequiredHgVersion(min = "1.7.0") @Test(dataProviderClass = HgVersionConstraint.class, dataProvider = "installedHgVersion") public class CollectChangesContextTest extends BaseMercurialTestCase { private ServerPluginConfig myConfig; private MercurialVcsSupport myVcs; private MercurialSupportBuilder myVcsBuilder; @BeforeMethod public void setUp() throws Exception { super.setUp(); myConfig = serverPluginConfig() .cachesDir(myTempFiles.createTempDir()) .hgPath(Util.getHgPath()) .build(); myVcsBuilder = mercurialSupport().withConfig(myConfig); myVcs = myVcsBuilder.build(); } @TestFor(issues = "TW-46340") public void test_many_from_revisions(@NotNull HgVersion version) throws Exception { //default // | branch1 // V | // V // 100 // /| //99 | // | | //..... total 100 merges from default into branch1 like this // | 5 // |/| // 4 | // | 3 // |/| // 2 | // |/ // 1 // | // 0 // // we collect changes from {default:99} to {default:99, branch1: 100} // when we compute from revisions for branch1 99 is enough (it will filter out all commits in the default branch) File remoteRepository = myTempFiles.createTempDir(); Util.copyRepository(new File("mercurial-tests/testData/manyFromRevisions"), remoteRepository); VcsRootImpl root = vcsRoot().withUrl(remoteRepository.getAbsolutePath()).build(); HgVcsRoot hgRoot = myVcsBuilder.getHgRootFactory().createHgRoot(root); RepositoryStateData fromState = RepositoryStateData.createVersionState("default", map("default", "d847416dd2eb")); RepositoryStateData toState = RepositoryStateData.createVersionState("default", map("default", "d847416dd2eb", "branch1", "8c990164b769")); CollectChangesContext context = new CollectChangesContext(myConfig, myVcs, myVcsBuilder.getHgRepoFactory(), MercurialProgress.NO_OP, fromState); Collection<String> fromRevisions = context.getFromRevisionsForBranch(hgRoot, "d847416dd2eb", "8c990164b769", toState); assertTrue(fromRevisions.size() == 1); assertTrue(fromRevisions.contains("d847416dd2eb")); } }