Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MergeSupportSubreposTest.java @ 915:6b5e83970a26 Hajipur-9.0.x
Fix test: test repository requires a more recent mercurial
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 02 Jan 2015 12:36:52 +0100 |
parents | 31a1aca3305c |
children | 7bf4d943d5bb |
line wrap: on
line source
/* * Copyright 2000-2014 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.vcs.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import java.util.List; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ModificationDataMatcher.modificationData; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItem; import static org.testng.AssertJUnit.assertFalse; @Test public class MergeSupportSubreposTest extends BaseMercurialTestCase { private File mySubrepo1; private File mySubrepo2; private MercurialVcsSupport myVcs; private MercurialMergeSupport myMergeSupport; @BeforeMethod @Override public void setUp() throws Exception { super.setUp(); File parentDir = myTempFiles.createTempDir(); mySubrepo1 = new File(parentDir, "subrepo1"); mySubrepo2 = new File(parentDir, "subrepo2"); mySubrepo1.mkdirs(); mySubrepo2.mkdirs(); copyRepository(new File("mercurial-tests/testData/merge/subrepos/subrepo1"), mySubrepo1); copyRepository(new File("mercurial-tests/testData/merge/subrepos/subrepo2"), mySubrepo2); ServerPluginConfig pluginConfig = new ServerPluginConfigBuilder() .cachesDir(myTempFiles.createTempDir()) .build(); MercurialSupportBuilder mercurialBuilder = mercurialSupport().withConfig(pluginConfig); myVcs = mercurialBuilder.build(); myMergeSupport = new MercurialMergeSupport(myVcs, myVcs.getMirrorManager(), pluginConfig, mercurialBuilder.getHgRootFactory(), mercurialBuilder.getHgRepoFactory()); } public void should_do_merge_in_subrepo_if_it_has_appropriate_branch() throws Exception { VcsRoot root = vcsRoot().withUrl(mySubrepo1).withSubrepoChanges(true).build(); RepositoryStateData beforeMerge = myVcs.getCollectChangesPolicy().getCurrentState(root); myMergeSupport.merge(root, "0bd1ae88632d", "default", "merge into default", new MergeOptions()); RepositoryStateData afterMerge = myVcs.getCollectChangesPolicy().getCurrentState(root); List<ModificationData> ms = myVcs.getCollectChangesPolicy().collectChanges(root, beforeMerge, afterMerge, CheckoutRules.DEFAULT); assertThat("Cannot find main repo merge commit", ms, hasItem(modificationData().withDescription("merge into default") .withParentRevisions("eb211547efbe", "0bd1ae88632d"))); assertThat("Cannot find subrepo merge commit", ms, hasItem(modificationData().withDescription("merge into default") .withParentRevisions("675fa105b184", "1532dee5d922"))); } public void should_report_conflicts_from_subrepos() throws Exception { VcsRoot root = vcsRoot().withUrl(mySubrepo1).withSubrepoChanges(true).build(); MergeResult result = myMergeSupport.merge(root, "3e43f76179ed", "default", "merge into default", new MergeOptions()); assertFalse(result.isSuccess()); assertThat("conflict from main repo is not reported", result.getConflicts(), hasItem("b/c")); assertThat("conflict from subrepo is not reported", result.getConflicts(), hasItem("subrepo2/b/c")); } }