Search in sources :

Example 11 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class AbstractScmProvider method changeLog.

/**
 * {@inheritDoc}
 *
 * @deprecated
 */
public ChangeLogScmResult changeLog(ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, String datePattern) throws ScmException {
    ScmVersion startRevision = null;
    ScmVersion endRevision = null;
    if (StringUtils.isNotEmpty(startTag)) {
        startRevision = new ScmRevision(startTag);
    }
    if (StringUtils.isNotEmpty(endTag)) {
        endRevision = new ScmRevision(endTag);
    }
    return changeLog(repository, fileSet, startRevision, endRevision, null);
}
Also used : ScmRevision(org.apache.maven.scm.ScmRevision) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 12 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class AccuRevCheckOutCommandTest method testCheckoutToVersionNewWorkspace.

@Test
public void testCheckoutToVersionNewWorkspace() throws Exception {
    when(accurev.mkws("anotherStream", AccuRevCheckOutCommand.getWorkSpaceName(basedir, "anotherStream"), basedir)).thenReturn(true);
    List<File> updatedFiles = Collections.singletonList(new File("updated/file"));
    when(accurev.update(basedir, "now")).thenReturn(updatedFiles);
    AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
    CommandParameters parameters = new CommandParameters();
    parameters.setScmVersion(CommandParameter.SCM_VERSION, new ScmRevision("anotherStream/12"));
    CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), parameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getCheckedOutFiles().size(), is(1));
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmRevision(org.apache.maven.scm.ScmRevision) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 13 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class AccuRevChangeLogCommandTest method testWorkspaceChangelog.

@Test
public void testWorkspaceChangelog() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
    final Date keepWhen = getDate(2009, 0, 2, 9, 0, 0, null);
    final Date promoteWhen = getDate(2009, 0, 4, 23, 0, 0, null);
    final Date fromDate = getDate(2009, 0, 1, 0, 0, 0, null);
    final Date toDate = getDate(2009, 0, 5, 1, 0, 0, null);
    // start tran (35)
    List<Transaction> startTransaction = Collections.singletonList(new Transaction(35L, fromDate, "sometran", "anyone"));
    when(accurev.history("workspace5", "35", null, 1, true, true)).thenReturn(startTransaction);
    // end tran (42)
    List<Transaction> endTransaction = Collections.singletonList(new Transaction(42L, toDate, "sometran", "anyone"));
    when(accurev.history("workspace5", "42", null, 1, true, true)).thenReturn(endTransaction);
    // Stream hierarchy
    // S2 < S4, S2 < WS3, S4 < WS5, S4 << WS7
    // 
    // Changelog(WS5,35,42) involves
    // -- diff(S4,35,42)
    // -- hist(WS5,36-42)
    // -- hist(S4,36-42)
    // 
    // Promote S4 to S2 - not in diffS4, not in histS4, not in hist WS5 -
    // not in changeset
    // Promote WS3 to S2 - in diffS4, not hist histS4, not in hist WS5 - in
    // "upstream changes"
    // Promote WS5 to S4 - in diffS4, in histS4, not in hist WS5 - not in
    // changeset (real version from WS5)
    // Promote WS7 to S4 - in diffS4, in histS4, not in hist WS5 - in
    // changeset as a promote transaction
    // Keep WS5 - not in diffS4, not in histS4, in histWS5 - in changeset as
    // a keep transaction
    // This workspace is stream 5, attached to basis mystream 5
    Stream workspaceStream = new Stream("workspace5", 5, "stream4", 4, "myDepot", getDate(2008, 10, 1, 10, 0, 0, null), "workspace");
    when(accurev.showStream("workspace5")).thenReturn(workspaceStream);
    Stream basisStream = new Stream("stream4", 4, "myDepot", 1, "myDepot", getDate(2008, 1, 1), "normal");
    when(accurev.showStream("stream4")).thenReturn(basisStream);
    // now we call diff between the tran ids - 35 to 42
    FileDifference diffWS3toS2 = new FileDifference(32L, "/promoted/WS3toS2", "3/2", "/promoted/WS3toS2", "6/1");
    FileDifference diffWS5toS4 = new FileDifference(54L, "/promoted/WS5toS4", "5/3", "/promoted/WS5toS4", "8/1");
    FileDifference diffWS7toS4 = new FileDifference(74L, "/promoted/WS7toS4", "7/12", "/promoted/WS7toS4", "3/13");
    when(accurev.diff("stream4", "35", "42")).thenReturn(Arrays.asList(diffWS3toS2, diffWS5toS4, diffWS7toS4));
    // and we call hist for tranid + 1 to end trand ii
    Transaction promoteWS5toS4 = new Transaction(37L, promoteWhen, "promote", "aUser");
    promoteWS5toS4.setComment("WS5toS4");
    promoteWS5toS4.addVersion(54L, "/./promoted/WS5toS4", "4/5", "5/3", "3/2");
    Transaction promoteWS7toS4 = new Transaction(38L, promoteWhen, "promote", "aUser");
    promoteWS7toS4.setComment("WS7toS4");
    promoteWS7toS4.addVersion(74L, "/./promoted/WS7toS4", "4/11", "7/12", "3/2");
    when(accurev.history("stream4", "36", "42", 0, false, false)).thenReturn(Arrays.asList(promoteWS5toS4, promoteWS7toS4));
    Transaction keepWS5 = new Transaction(39L, keepWhen, "keep", "anOther");
    keepWS5.addVersion(5L, "/./kept/WS5", "5/7", "5/7", "7/21");
    keepWS5.setComment("keepWS5");
    when(accurev.history("workspace5", "36", "42", 0, false, false)).thenReturn(Collections.singletonList(keepWS5));
    AccuRevChangeLogCommand command = new AccuRevChangeLogCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setScmVersion(CommandParameter.START_SCM_VERSION, new ScmRevision("workspace5/35"));
    commandParameters.setScmVersion(CommandParameter.END_SCM_VERSION, new ScmRevision("workspace5/42"));
    ChangeLogScmResult result = command.changelog(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    ChangeLogSet changelog = result.getChangeLog();
    assertThat(changelog.getStartVersion().getName(), is("workspace5/35"));
    assertThat(changelog.getEndVersion().getName(), is("workspace5/42"));
    List<ChangeSet> changesets = changelog.getChangeSets();
    assertThat(changesets.size(), is(3));
    for (ChangeSet changeSet : changesets) {
        assertThat(changeSet.getComment(), isOneOf("Upstream changes", "WS7toS4", "keepWS5"));
        if ("Upstream changes".equals(changeSet.getComment())) {
            assertThat(changeSet.getFiles().size(), is(1));
            ChangeFile changeFile = (ChangeFile) changeSet.getFiles().get(0);
            assertThat(changeFile, is(changeFile("/promoted/WS3toS2")));
        }
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ScmRevision(org.apache.maven.scm.ScmRevision) Date(java.util.Date) Transaction(org.apache.maven.scm.provider.accurev.Transaction) ChangeFile(org.apache.maven.scm.ChangeFile) Stream(org.apache.maven.scm.provider.accurev.Stream) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) FileDifference(org.apache.maven.scm.provider.accurev.FileDifference) CommandParameters(org.apache.maven.scm.CommandParameters) ChangeFile(org.apache.maven.scm.ChangeFile) ChangeFileMatcher.changeFile(org.apache.maven.scm.ChangeFileMatcher.changeFile) File(java.io.File) ChangeSet(org.apache.maven.scm.ChangeSet) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 14 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class AccuRevChangeLogCommandTest method testChangeLogBetweenStreamsUnsupported.

@Test
public void testChangeLogBetweenStreamsUnsupported() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
    AccuRevChangeLogCommand command = new AccuRevChangeLogCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.START_SCM_VERSION, new ScmRevision("aStream/12"));
    params.setScmVersion(CommandParameter.END_SCM_VERSION, new ScmRevision("anotherStream/20"));
    try {
        command.changelog(repo, testFileSet, params);
        fail("Expected accurev exception");
    } catch (ScmException e) {
    // Expected
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmException(org.apache.maven.scm.ScmException) ScmRevision(org.apache.maven.scm.ScmRevision) CommandParameters(org.apache.maven.scm.CommandParameters) ChangeFile(org.apache.maven.scm.ChangeFile) ChangeFileMatcher.changeFile(org.apache.maven.scm.ChangeFileMatcher.changeFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 15 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class TfsUpdateCommandTest method testCommandline.

public void testCommandline() throws Exception {
    TfsScmProviderRepository repo = getScmProviderRepository();
    ScmRevision rev = new ScmRevision("revision");
    Commandline cmd = new TfsUpdateCommand().createCommand(repo, getScmFileSet(), rev).getCommandline();
    String path = repo.getServerPath();
    String expected = "tf get -login:user,password " + path + " -version:Crevision";
    assertCommandLine(expected, getWorkingDirectory(), cmd);
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ScmRevision(org.apache.maven.scm.ScmRevision) TfsScmProviderRepository(org.apache.maven.scm.provider.tfs.TfsScmProviderRepository)

Aggregations

ScmRevision (org.apache.maven.scm.ScmRevision)28 File (java.io.File)12 ScmFileSet (org.apache.maven.scm.ScmFileSet)12 Commandline (org.codehaus.plexus.util.cli.Commandline)10 Date (java.util.Date)5 CommandParameters (org.apache.maven.scm.CommandParameters)5 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)5 Test (org.junit.Test)5 ChangeFile (org.apache.maven.scm.ChangeFile)4 ScmException (org.apache.maven.scm.ScmException)4 ScmFile (org.apache.maven.scm.ScmFile)4 ScmVersion (org.apache.maven.scm.ScmVersion)4 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)4 ScmRepository (org.apache.maven.scm.repository.ScmRepository)4 ChangeFileMatcher.changeFile (org.apache.maven.scm.ChangeFileMatcher.changeFile)3 ScmBranch (org.apache.maven.scm.ScmBranch)3 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)3 FileDifference (org.apache.maven.scm.provider.accurev.FileDifference)3 Stream (org.apache.maven.scm.provider.accurev.Stream)3 Transaction (org.apache.maven.scm.provider.accurev.Transaction)3