Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java @ 977:38adef4f1b8f Indore-2017.2.x
Update copyright
author | pavel.sher |
---|---|
date | Mon, 22 Jan 2018 11:40:45 +0100 |
parents | 31a1aca3305c |
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.AuthSettings; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory; import jetbrains.buildServer.vcs.*; import org.jetbrains.annotations.NotNull; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.util.List; import java.util.Map; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.buildPatch; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; @Test public class RevisionFormatTest extends BaseMercurialPatchTestCase { private MercurialVcsSupport myVcs; private VcsRoot myRoot; private File myRemoteRepoDir; @BeforeMethod public void setUp() throws Exception { super.setUp(); ServerPluginConfig pluginConfig = new ServerPluginConfigBuilder() .cachesDir(myTempFiles.createTempDir()) .build(); myVcs = mercurialSupport().withConfig(pluginConfig).build(); myRemoteRepoDir = copyRepository(myTempFiles, new File("mercurial-tests/testData/rep1").getAbsolutePath()); myRoot = vcsRoot().withUrl(myRemoteRepoDir.getAbsolutePath()).build(); } public void collect_changes_result_does_not_depend_on_revnums() throws VcsException { List<ModificationData> changesWithRevnums = myVcs.getCollectChangesPolicy().collectChanges(myRoot, "1:1d446e82d356", "3:9522278aa38d", CheckoutRules.DEFAULT); List<ModificationData> changesWithoutRevnums = myVcs.getCollectChangesPolicy().collectChanges(myRoot, "1d446e82d356", "9522278aa38d", CheckoutRules.DEFAULT); assertEquals(changesWithoutRevnums, changesWithRevnums); } public void labeling_does_not_depend_on_revnums() throws Exception { myVcs.label("tag1", "3:9522278aa38d", myRoot, CheckoutRules.DEFAULT); myVcs.label("tag2", "9522278aa38d", myRoot, CheckoutRules.DEFAULT); HgRepo repo = createRepo(myRemoteRepoDir); String tag1 = repo.id().inLocalRepository().namedRevision("tag1").call(); String tag2 = repo.id().inLocalRepository().namedRevision("tag2").call(); assertEquals(tag2, tag1); } public void get_file_content_does_not_depend_on_revnums() throws Exception { byte[] contentWithRevnums = myVcs.getContent("dir1/file4.txt", myRoot, "2:7209b1f1d793"); byte[] contentWithoutRevnums = myVcs.getContent("dir1/file4.txt", myRoot, "7209b1f1d793"); assertEquals(contentWithoutRevnums, contentWithRevnums); } public void clean_patch_does_not_depend_on_revnums() throws Exception { setName("cleanPatch1_checkout_rules"); ByteArrayOutputStream output = buildPatch(myVcs, myRoot, null, "4:b06a290a363b", new CheckoutRules("+:dir1/subdir=>.")); checkPatchResult(output.toByteArray()); output = buildPatch(myVcs, myRoot, null, "b06a290a363b", new CheckoutRules("+:dir1/subdir=>.")); checkPatchResult(output.toByteArray()); } public void incremental_patch_does_not_depend_on_revnums() throws Exception { setName("patch2"); ByteArrayOutputStream output = buildPatch(myVcs, myRoot, "3:9522278aa38d", "6:b9deb9a1c6f4", CheckoutRules.DEFAULT); checkPatchResult(output.toByteArray()); output = buildPatch(myVcs, myRoot, "9522278aa38d", "6:b9deb9a1c6f4", CheckoutRules.DEFAULT); checkPatchResult(output.toByteArray()); output = buildPatch(myVcs, myRoot, "3:9522278aa38d", "b9deb9a1c6f4", CheckoutRules.DEFAULT); checkPatchResult(output.toByteArray()); output = buildPatch(myVcs, myRoot, "9522278aa38d", "b9deb9a1c6f4", CheckoutRules.DEFAULT); checkPatchResult(output.toByteArray()); } public void should_not_include_revnum_in_current_version() throws VcsException { RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot); String currentVersion = state.getBranchRevisions().get(state.getDefaultBranchName()); assertFalse(currentVersion.contains(":")); } public void should_not_include_revnum_in_current_state() throws VcsException { RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot); for (Map.Entry<String, String> entry : state.getBranchRevisions().entrySet()) { String branchName = entry.getKey(); String revision = entry.getKey(); assertFalse(revision.contains(":"), "Revision of branch " + branchName + " contains revnum: " + revision); } } public void should_not_include_revnum_in_collected_changes() throws VcsException { List<ModificationData> changes = myVcs.getCollectChangesPolicy().collectChanges(myRoot, "1d446e82d356", "9522278aa38d", CheckoutRules.DEFAULT); for (ModificationData c : changes) { assertFalse(c.getVersion().contains(":"), "Change version contains revnum: " + c.toString()); for (String parentVersion : c.getParentRevisions()) { assertFalse(parentVersion.contains(":"), "Parent version contains revnum: " + c.toString()); } for (VcsChange changedFile : c.getChanges()) { assertFalse(changedFile.getAfterChangeRevisionNumber().contains(":"), "Vcs change contains revnum : " + changedFile.toString()); assertFalse(changedFile.getBeforeChangeRevisionNumber().contains(":"), "Vcs change contains revnum : " + changedFile.toString()); } } } @Override protected String getTestDataPath() { return "mercurial-tests/testData"; } private HgRepo createRepo(@NotNull File dir) throws IOException { return new HgRepo(new TestCommandSettingsFactory(), dir, Util.getHgPath(), new AuthSettings()); } }