Search in sources :

Example 36 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class BazaarScmProvider method checkout.

/**
 * {@inheritDoc}
 */
public CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    BazaarCheckOutCommand command = new BazaarCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : BazaarCheckOutCommand(org.apache.maven.scm.provider.bazaar.command.checkout.BazaarCheckOutCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 37 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class VssScmProvider method checkout.

/**
 * {@inheritDoc}
 */
public CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    VssCheckOutCommand command = new VssCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) VssCheckOutCommand(org.apache.maven.scm.provider.vss.commands.checkout.VssCheckOutCommand)

Example 38 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class TfsCheckOutCommand method executeCheckOutCommand.

protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository r, ScmFileSet f, ScmVersion v, boolean recursive, boolean shallow) throws ScmException {
    TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r;
    String url = tfsRepo.getServerPath();
    String tfsUrl = tfsRepo.getTfsUrl();
    String workspace = tfsRepo.getWorkspace();
    // Try creating workspace
    boolean workspaceProvided = workspace != null && !workspace.trim().equals("");
    if (workspaceProvided) {
        createWorkspace(r, f, workspace, tfsUrl);
    }
    TfsCommand command;
    int status;
    if (workspaceProvided) {
        status = executeUnmapCommand(r, f);
    }
    ErrorStreamConsumer out = new ErrorStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    if (workspaceProvided) {
        command = new TfsCommand("workfold", r, null, getLogger());
        command.addArgument("-workspace:" + workspace);
        command.addArgument("-map");
        command.addArgument(url);
        command.addArgument(f.getBasedir().getAbsolutePath());
        status = command.execute(out, err);
        if (status != 0 || err.hasBeenFed()) {
            return new CheckOutScmResult(command.getCommandString(), "Error code for TFS checkout (workfold map) command - " + status, err.getOutput(), false);
        }
    }
    FileListConsumer fileConsumer = new FileListConsumer();
    err = new ErrorStreamConsumer();
    command = createGetCommand(r, f, v, recursive);
    status = command.execute(fileConsumer, err);
    if (status != 0 || err.hasBeenFed()) {
        return new CheckOutScmResult(command.getCommandString(), "Error code for TFS checkout (get) command - " + status, err.getOutput(), false);
    }
    return new CheckOutScmResult(command.getCommandString(), fileConsumer.getFiles());
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) TfsScmProviderRepository(org.apache.maven.scm.provider.tfs.TfsScmProviderRepository) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 39 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class CheckInCommandTckTest method testCheckInCommandTest.

public void testCheckInCommandTest() throws Exception {
    // Make sure that the correct files was checked out
    File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java");
    File barJava = new File(getWorkingCopy(), "src/main/java/Bar.java");
    File readmeTxt = new File(getWorkingCopy(), "readme.txt");
    assertFalse("check Foo.java doesn't yet exist", fooJava.canRead());
    assertFalse("check Bar.java doesn't yet exist", barJava.canRead());
    assertTrue("check can read readme.txt", readmeTxt.canRead());
    // Change the files
    createFooJava(fooJava);
    createBarJava(barJava);
    changeReadmeTxt(readmeTxt);
    AddScmResult addResult = getScmManager().add(getScmRepository(), new ScmFileSet(getWorkingCopy(), "src/main/java/Foo.java", null));
    assertResultIsSuccess(addResult);
    CheckInScmResult result = getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "Commit message");
    assertResultIsSuccess(result);
    List<ScmFile> files = result.getCheckedInFiles();
    assertNotNull(files);
    assertEquals(2, files.size());
    Map<String, ScmFile> fileMap = mapFilesByPath(files);
    ScmFile file1 = fileMap.get("src/main/java/Foo.java");
    assertNotNull(file1);
    assertEquals(ScmFileStatus.CHECKED_IN, file1.getStatus());
    ScmFile file2 = fileMap.get("readme.txt");
    assertNotNull(file2);
    assertEquals(ScmFileStatus.CHECKED_IN, file2.getStatus());
    CheckOutScmResult checkoutResult = getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()));
    assertResultIsSuccess(checkoutResult);
    fooJava = new File(getAssertionCopy(), "src/main/java/Foo.java");
    barJava = new File(getAssertionCopy(), "src/main/java/Bar.java");
    readmeTxt = new File(getAssertionCopy(), "readme.txt");
    assertTrue("check can read Foo.java", fooJava.canRead());
    assertFalse("check Bar.java doesn't exist", barJava.canRead());
    assertTrue("check can read readme.txt", readmeTxt.canRead());
    assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt));
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Example 40 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class HgScmProvider method checkout.

/**
 * {@inheritDoc}
 */
public CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    HgCheckOutCommand command = new HgCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : HgCheckOutCommand(org.apache.maven.scm.provider.hg.command.checkout.HgCheckOutCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Aggregations

CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)57 File (java.io.File)24 ScmFileSet (org.apache.maven.scm.ScmFileSet)20 ScmFile (org.apache.maven.scm.ScmFile)14 ScmException (org.apache.maven.scm.ScmException)11 ScmTag (org.apache.maven.scm.ScmTag)9 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)8 Test (org.junit.Test)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)7 IOException (java.io.IOException)6 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)6 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)6 ScmManager (org.apache.maven.scm.manager.ScmManager)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)5 ArrayList (java.util.ArrayList)4 ScmResult (org.apache.maven.scm.ScmResult)4 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)3