Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java @ 271:c0540bbe7c2a
Revert premature commit. Parents are not part of API yet
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 20 Jul 2011 17:40:04 +0400 |
parents | 0af40adc4791 |
children | 8c10f5cec37d |
line wrap: on
line source
/* * Copyright 2000-2011 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.command; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; import java.util.List; @Test public class LogCommandTest extends BaseCommandTestCase { @BeforeMethod @Override protected void setUp() throws Exception { super.setUp(); setRepository("mercurial-tests/testData/rep1", true); } public void testOneChangeSet() throws Exception { final String toId = "9875b412a788"; List<ChangeSet> changes = runLog(null, toId); assertEquals(1, changes.size()); final ChangeSet changeSet = changes.get(0); assertEquals(0, changeSet.getRevNumber()); assertEquals(toId, changeSet.getId()); assertEquals("pavel@localhost", changeSet.getUser()); assertEquals("dir1 created", changeSet.getDescription()); assertNull(changeSet.getParents()); } public void testMoreThanOneChangeSet() throws Exception { final String fromId = "9875b412a788"; final String toId = "7209b1f1d793"; List<ChangeSet> changes = runLog(fromId, toId); assertEquals(3, changes.size()); ChangeSet changeSet1 = changes.get(0); final ChangeSet changeSet2 = changes.get(1); final ChangeSet changeSet3 = changes.get(2); assertEquals("dir1 created", changeSet1.getDescription()); assertEquals("new file added", changeSet2.getDescription()); assertEquals("file4.txt added", changeSet3.getDescription()); changes = runLog(null, toId); assertEquals(3, changes.size()); changeSet1 = changes.get(2); assertEquals("file4.txt added", changeSet1.getDescription()); } public void changeset_parents() throws VcsException, IOException { setRepository("mercurial-tests/testData/rep2", true); List<ChangeSet> changes = runLog("6eeb8974fe67", "6eeb8974fe67"); assertEquals(1, changes.size()); ChangeSet cs = changes.get(0); assertNotNull(cs.getParents()); assertEquals(2, cs.getParents().size()); assertTrue(cs.getParents().contains(new ChangeSetRevision("1:a3d15477d297"))); assertTrue(cs.getParents().contains(new ChangeSetRevision("3:2538c02bafeb"))); } public void parse_multiline_description() throws VcsException, IOException { List<ChangeSet> changes = runLog("9babcf2d5705", "9c6a6b4aede0"); assertEquals(1, changes.size()); assertEquals("Multiline description\n" + "description with new\n" + "lines\n" + "aaaa\n" + "bbb", changes.get(0).getDescription()); } private List<ChangeSet> runLog(final String fromId, final String toId) throws IOException, VcsException { return runCommand(new CommandExecutor<List<ChangeSet>>() { public List<ChangeSet> execute(@NotNull final Settings settings, @NotNull File workingDir) throws VcsException { LogCommand lc = new LogCommand(settings, workingDir); lc.setFromRevId(fromId); lc.setToRevId(toId); return lc.execute(); } }); } }