Search in sources :

Example 51 with ScmFile

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

the class TfsCheckOutCommandTest method testCommand.

public void testCommand() {
    consumer.consumeLine("C:\\temp\\maven\\c8:");
    consumer.consumeLine("Replacing .tpattributes");
    consumer.consumeLine("Replacing .classpath");
    consumer.consumeLine("Replacing .myclasspath");
    consumer.consumeLine("Replacing .project");
    consumer.consumeLine("");
    consumer.consumeLine("C:\\temp\\maven\\c8\\.settings:");
    consumer.consumeLine("");
    consumer.consumeLine("C:\\temp\\maven\\c8:");
    consumer.consumeLine("Replacing .tpignore");
    consumer.consumeLine("Replacing about.html");
    consumer.consumeLine("");
    consumer.consumeLine("C:\\temp\\maven\\c8\\bin:");
    consumer.consumeLine("");
    consumer.consumeLine("C:\\temp\\maven\\c8:");
    consumer.consumeLine("Replacing build.properties");
    consumer.consumeLine("Replacing customBuildCallbacks.xml");
    consumer.consumeLine("");
    String exp1 = new File("C:\\temp\\maven\\c8", ".classpath").getAbsolutePath();
    String exp2 = new File("C:\\temp\\maven\\c8", "build.properties").getAbsolutePath();
    ScmFile expFile1 = new ScmFile(exp1, ScmFileStatus.CHECKED_OUT);
    ScmFile expFile2 = new ScmFile(exp2, ScmFileStatus.CHECKED_OUT);
    assertNotNull(consumer.getFiles());
    assertEquals(11, consumer.getFiles().size());
    assertTrue(consumer.getFiles().contains(expFile1));
    assertTrue(consumer.getFiles().contains(expFile2));
}
Also used : ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 52 with ScmFile

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

the class ChangedFileConsumer method extractChangedFile.

private void extractChangedFile() {
    String change = getChange();
    if (change != null) {
        ScmFileStatus stat = ScmFileStatus.UNKNOWN;
        if (change.equals(ChangedFileConsumer.CHANGE_EDIT)) {
            stat = ScmFileStatus.MODIFIED;
        }
        if (change.equals(ChangedFileConsumer.CHANGE_ADD)) {
            stat = ScmFileStatus.ADDED;
        }
        changedFiles.add(new ScmFile(getLocalPath(), stat));
        values.clear();
    }
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) ScmFile(org.apache.maven.scm.ScmFile)

Example 53 with ScmFile

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

the class FileListConsumer method consumeLine.

public void consumeLine(String line) {
    fed = true;
    if (line.endsWith(":")) {
        currentDir = line.substring(0, line.lastIndexOf(':'));
        ScmFile scmFile = new ScmFile(currentDir, ScmFileStatus.CHECKED_OUT);
        if (!files.contains(scmFile)) {
            files.add(scmFile);
        }
    } else if (line.trim().equals("")) {
        currentDir = "";
    } else if (!currentDir.equals("") && line.indexOf(' ') >= 0) {
        String filename = line.split(" ")[1];
        files.add(getScmFile(filename));
    } else {
        files.add(getScmFile(line));
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 54 with ScmFile

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

the class MavenScmCli method checkOut.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
private void checkOut(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException {
    if (workingDirectory.exists()) {
        System.err.println("The working directory already exist: '" + workingDirectory.getAbsolutePath() + "'.");
        return;
    }
    if (!workingDirectory.mkdirs()) {
        System.err.println("Error while making the working directory: '" + workingDirectory.getAbsolutePath() + "'.");
        return;
    }
    CheckOutScmResult result = scmManager.checkOut(scmRepository, new ScmFileSet(workingDirectory), version);
    if (!result.isSuccess()) {
        showError(result);
        return;
    }
    List<ScmFile> checkedOutFiles = result.getCheckedOutFiles();
    System.out.println("Checked out these files: ");
    for (ScmFile file : checkedOutFiles) {
        System.out.println(" " + file.getPath());
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Example 55 with ScmFile

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

the class MavenScmCli method update.

private void update(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException {
    if (!workingDirectory.exists()) {
        System.err.println("The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() + "'.");
        return;
    }
    UpdateScmResult result = scmManager.update(scmRepository, new ScmFileSet(workingDirectory), version);
    if (!result.isSuccess()) {
        showError(result);
        return;
    }
    List<ScmFile> updatedFiles = result.getUpdatedFiles();
    System.out.println("Updated these files: ");
    for (ScmFile file : updatedFiles) {
        System.out.println(" " + file.getPath());
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

ScmFile (org.apache.maven.scm.ScmFile)198 File (java.io.File)102 ArrayList (java.util.ArrayList)51 ScmException (org.apache.maven.scm.ScmException)34 BufferedReader (java.io.BufferedReader)21 DefaultLog (org.apache.maven.scm.log.DefaultLog)20 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)19 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 InputStreamReader (java.io.InputStreamReader)16 ScmResult (org.apache.maven.scm.ScmResult)15 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)15 IOException (java.io.IOException)14 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)13 Matcher (java.util.regex.Matcher)11 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)11 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)10 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)10 Commandline (org.codehaus.plexus.util.cli.Commandline)10 SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)9 FileInputStream (java.io.FileInputStream)8