Search in sources :

Example 16 with ScmTag

use of org.apache.maven.scm.ScmTag in project maven-plugins by apache.

the class ChangeLogHandler method startElement.

/**
 * {@inheritDoc}
 */
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    bufData = "";
    if ("file".equals(qName)) {
        bufFile = new ChangeFile("");
    } else if ("changelog-entry".equals(qName)) {
        bufEntry = new ChangeSet();
    } else if ("date".equals(qName)) {
        currentPattern = attributes.getValue("pattern");
        if (currentPattern == null) {
            currentPattern = "yyyy-MM-dd";
        }
    } else if ("time".equals(qName)) {
        currentPattern = attributes.getValue("pattern");
        if (currentPattern == null) {
            currentPattern = "HH:mm:ss";
        }
    } else if ("changeset".equals(qName)) {
        bufEntries = new LinkedList<ChangeSet>();
        currentPattern = attributes.getValue("datePattern");
        if (currentPattern == null) {
            currentPattern = "yyyy-MM-dd";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(currentPattern);
        String start = attributes.getValue("start");
        String end = attributes.getValue("end");
        Date startDate = null;
        Date endDate = null;
        if (start != null) {
            try {
                startDate = formatter.parse(start);
            } catch (ParseException e) {
                throw new SAXException("Can't parse start date '" + start + "'.", e);
            }
        }
        if (end != null) {
            try {
                endDate = formatter.parse(end);
            } catch (ParseException e) {
                throw new SAXException("Can't parse end date '" + end + "'.", e);
            }
        }
        bufSet = new ChangeLogSet(bufEntries, startDate, endDate);
        String startVersion = attributes.getValue("startVersion");
        if (startVersion != null) {
            bufSet.setStartVersion(new ScmTag(startVersion));
        }
        String endVersion = attributes.getValue("endVersion");
        if (endVersion != null) {
            bufSet.setEndVersion(new ScmTag(endVersion));
        }
    }
}
Also used : ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ChangeFile(org.apache.maven.scm.ChangeFile) ScmTag(org.apache.maven.scm.ScmTag) ParseException(java.text.ParseException) ChangeSet(org.apache.maven.scm.ChangeSet) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) SAXException(org.xml.sax.SAXException)

Example 17 with ScmTag

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

the class AccuRevCheckOutCommandTest method testReCheckoutExistingWorkspaceDifferentBasis.

@Test
public void testReCheckoutExistingWorkspaceDifferentBasis() throws Exception {
    // Set the info result to return a workspace that already exists
    info.setWorkSpace("someOldStream_someUser");
    info.setBasis("myStream");
    info.setTop(basedir.getAbsolutePath());
    when(accurev.chws(basedir, "someOldStream_someUser", "mySnapShot")).thenReturn(true);
    List<File> emptyPop = Collections.emptyList();
    when(accurev.popExternal(basedir, null, null, null)).thenReturn(emptyPop);
    List<File> updatedFiles = Collections.singletonList(new File("updated/file"));
    when(accurev.update(basedir, null)).thenReturn(updatedFiles);
    AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
    CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), params);
    verify(accurev).chws(basedir, "someOldStream_someUser", "mySnapShot");
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getRelativePathProjectDirectory(), is("/project/dir"));
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) 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 18 with ScmTag

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

the class AccuRevExportCommandTest method testExportToVersionPre490.

@Test
public void testExportToVersionPre490() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    // A version that does not support pop -t
    when(accurev.getClientVersion()).thenReturn("4.7.4b");
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("now"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 19 with ScmTag

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

the class AccuRevExportCommandTest method testExportToVersion490.

@Test
public void testExportToVersion490() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    // A version that does not support pop -t
    when(accurev.getClientVersion()).thenReturn("4.9.0");
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("676"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
    verify(accurev).syncReplica();
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 20 with ScmTag

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

the class AccuRevExportCommandTest method testExportVersionOutSideWorkspace.

@Test
public void testExportVersionOutSideWorkspace() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq((String) null), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Aggregations

ScmTag (org.apache.maven.scm.ScmTag)32 File (java.io.File)17 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 Test (org.junit.Test)9 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)7 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)6 ScmBranch (org.apache.maven.scm.ScmBranch)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 ScmException (org.apache.maven.scm.ScmException)4 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)4 ScmFile (org.apache.maven.scm.ScmFile)3 ScmManager (org.apache.maven.scm.manager.ScmManager)3 SimpleDateFormat (java.text.SimpleDateFormat)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)2 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)2