Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java @ 86:948a35b430e1 Darjeeling-5.0.x
report parent changesets
author | Pavel.Sher |
---|---|
date | Tue, 08 Dec 2009 19:49:28 +0300 |
parents | 3cb4f95a4f6f |
children | 6fada1d52902 |
line wrap: on
line source
/* * Copyright 2000-2007 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.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.getSummary()); 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.getSummary()); assertEquals("new file added", changeSet2.getSummary()); assertEquals("file4.txt added", changeSet3.getSummary()); changes = runLog(null, toId); assertEquals(3, changes.size()); changeSet1 = changes.get(2); assertEquals("file4.txt added", changeSet1.getSummary()); } public void changeset_parents() throws VcsException, IOException { List<ChangeSet> changes = runLog("ae4f72cfa9d4", "ae4f72cfa9d4"); assertEquals(1, changes.size()); ChangeSet cs = changes.get(0); assertNotNull(cs.getParents()); assertEquals(1, cs.getParents().size()); assertEquals(new ChangeSetRevision("6:b9deb9a1c6f4"), cs.getParents().get(0)); changes = runLog("1870e1100fab", "1870e1100fab"); assertEquals(1, changes.size()); assertEquals(2, changes.get(0).getParents().size()); } 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) throws VcsException { LogCommand lc = new LogCommand(settings); lc.setFromRevId(fromId); lc.setToRevId(toId); return lc.execute(); } }); } }