Search in sources :

Example 1 with ScmFileStatus

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

the class BazaarConsumer method consumeLine.

/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(line);
    }
    String trimmedLine = line.trim();
    String statusStr = processInputForKnownIdentifiers(trimmedLine);
    // If its not a status report - then maybe its a message?
    if (statusStr == null) {
        boolean isMessage = processInputForKnownMessages(trimmedLine);
        // If it is then its already processed and we can ignore futher processing
        if (isMessage) {
            return;
        }
    } else {
        // Strip away identifier
        trimmedLine = trimmedLine.substring(statusStr.length());
        // one or more spaces
        trimmedLine = trimmedLine.trim();
    }
    ScmFileStatus status = statusStr != null ? ((ScmFileStatus) IDENTIFIERS.get(statusStr.intern())) : null;
    doConsume(status, trimmedLine);
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus)

Example 2 with ScmFileStatus

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

the class SvnChangeLogConsumer method processGetFile.

/**
 * Process the current input line in the GET_FILE state.  This state
 * adds each file entry line to the current change log entry.  Note,
 * the revision number for the entire entry is used for the revision
 * number of each file.
 *
 * @param line A line of text from the svn log output
 */
private void processGetFile(String line) {
    Matcher matcher = FILE_PATTERN.matcher(line);
    if (matcher.matches()) {
        final String fileinfo = matcher.group(2);
        String name = fileinfo;
        String originalName = null;
        String originalRev = null;
        final int n = fileinfo.indexOf(" (");
        if (n > 1 && fileinfo.endsWith(")")) {
            final String origFileInfo = fileinfo.substring(n);
            Matcher matcher2 = ORIG_FILE_PATTERN.matcher(origFileInfo);
            if (matcher2.find()) {
                // if original file is present, we must extract the affected one from the beginning
                name = fileinfo.substring(0, n);
                originalName = matcher2.group(1);
                originalRev = matcher2.group(2);
            }
        }
        final String actionStr = matcher.group(1);
        final ScmFileStatus action;
        if ("A".equals(actionStr)) {
            // TODO: this may even change to MOVED if we later explore whole changeset and find matching DELETED
            action = originalRev == null ? ScmFileStatus.ADDED : ScmFileStatus.COPIED;
        } else if ("D".equals(actionStr)) {
            action = ScmFileStatus.DELETED;
        } else if ("M".equals(actionStr)) {
            action = ScmFileStatus.MODIFIED;
        } else if ("R".equals(actionStr)) {
            // == REPLACED in svn terms
            action = ScmFileStatus.UPDATED;
        } else {
            action = ScmFileStatus.UNKNOWN;
        }
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(actionStr + " : " + name);
        }
        final ChangeFile changeFile = new ChangeFile(name, currentRevision);
        changeFile.setAction(action);
        changeFile.setOriginalName(originalName);
        changeFile.setOriginalRevision(originalRev);
        currentChange.addFile(changeFile);
        status = GET_FILE;
    } else if (line.equals(FILE_END_TOKEN)) {
        // Create a buffer for the collection of the comment now
        // that we are leaving the GET_FILE state.
        currentComment = new StringBuilder();
        status = GET_COMMENT;
    }
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) Matcher(java.util.regex.Matcher) ChangeFile(org.apache.maven.scm.ChangeFile)

Example 3 with ScmFileStatus

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

the class PerforceCheckOutConsumer method consumeLine.

/*
     * Client mperham-mikeperham-dt-maven saved.
     */
/*
     * //depot/modules/cordoba/runtime-ear/.j2ee#1 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\.j2ee
     * //depot/modules/cordoba/runtime-ear/.project#1 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\.project
     * //depot/modules/cordoba/runtime-ear/.runtime#1 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\.runtime
     * //depot/modules/cordoba/runtime-ear/Foo.java#1 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\Foo.java
     * //depot/modules/cordoba/runtime-ear/META-INF/.modulemaps#1 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\META-INF\.modulemaps
     * //depot/modules/cordoba/runtime-ear/META-INF/application.xml#1 - deleted
     * as d:\perforce\depot\modules\cordoba\runtime-ear\META-INF\application.xml
     * //depot/modules/cordoba/runtime-ear/pom.xml#4 - deleted as
     * d:\perforce\depot\modules\cordoba\runtime-ear\pom.xml
     */
/*
     * Invalid changelist/client/label/date '@somelabel'.
     */
/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (currentState == STATE_CLIENTSPEC && (line.startsWith("Client " + specname + " saved.") || line.startsWith("Client " + specname + " not changed."))) {
        currentState = STATE_NORMAL;
        return;
    }
    // Handle case where the clientspec is current
    if (currentState == STATE_NORMAL && line.indexOf("ile(s) up-to-date") != -1) {
        return;
    }
    Matcher matcher;
    if (currentState != STATE_ERROR && (matcher = fileRegexp.matcher(line)).find()) {
        String location = matcher.group(1);
        if (location.startsWith(repo)) {
            location = location.substring(repo.length() + 1);
        }
        ScmFileStatus status = PerforceVerbMapper.toStatus(matcher.group(2));
        if (status != null) {
            // there are cases where Perforce prints out something but the file did not
            // actually change (especially when force syncing).  Those files will have
            // a null status.
            checkedout.add(new ScmFile(location, status));
        }
        return;
    }
    error(line);
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) Matcher(java.util.regex.Matcher) ScmFile(org.apache.maven.scm.ScmFile)

Example 4 with ScmFileStatus

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

the class LocalUpdateCommand method update.

private List<ScmFile> update(File source, File baseDestination, List<File> files) throws ScmException, IOException {
    String sourcePath = source.getAbsolutePath();
    List<ScmFile> updatedFiles = new ArrayList<ScmFile>();
    for (Iterator<File> i = files.iterator(); i.hasNext(); ) {
        File repositoryFile = i.next();
        File repositoryDirectory = repositoryFile.getParentFile();
        // TODO: Add more excludes here
        if (repositoryDirectory != null && repositoryDirectory.getName().equals("CVS")) {
            continue;
        }
        String dest = repositoryFile.getAbsolutePath().substring(sourcePath.length() + 1);
        File destinationFile = new File(baseDestination, dest);
        String repositoryFileContents = FileUtils.fileRead(repositoryFile);
        if (destinationFile.exists()) {
            String destionationFileContents = FileUtils.fileRead(destinationFile);
            if (repositoryFileContents.equals(destionationFileContents)) {
                continue;
            }
        }
        File destinationDirectory = destinationFile.getParentFile();
        if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
            throw new ScmException("Could not create destination directory '" + destinationDirectory.getAbsolutePath() + "'.");
        }
        ScmFileStatus status;
        if (destinationFile.exists()) {
            status = ScmFileStatus.UPDATED;
        } else {
            status = ScmFileStatus.ADDED;
        }
        FileUtils.copyFileToDirectory(repositoryFile, destinationDirectory);
        int chop = baseDestination.getAbsolutePath().length();
        String fileName = "/" + destinationFile.getAbsolutePath().substring(chop + 1);
        updatedFiles.add(new ScmFile(fileName, status));
    }
    return updatedFiles;
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) ScmException(org.apache.maven.scm.ScmException) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 5 with ScmFileStatus

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

the class HgConsumer method consumeLine.

/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(line);
    }
    String trimmedLine = line.trim();
    String statusStr = processInputForKnownIdentifiers(trimmedLine);
    // If its not a status report - then maybe its a message?
    if (statusStr == null) {
        boolean isMessage = processInputForKnownMessages(trimmedLine);
        // If it is then its already processed and we can ignore futher processing
        if (isMessage) {
            return;
        }
    } else {
        // Strip away identifier
        trimmedLine = trimmedLine.substring(statusStr.length());
        // one or more spaces
        trimmedLine = trimmedLine.trim();
    }
    ScmFileStatus status = statusStr != null ? ((ScmFileStatus) IDENTIFIERS.get(statusStr.intern())) : null;
    doConsume(status, trimmedLine);
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus)

Aggregations

ScmFileStatus (org.apache.maven.scm.ScmFileStatus)24 ScmFile (org.apache.maven.scm.ScmFile)17 File (java.io.File)7 Matcher (java.util.regex.Matcher)6 ChangeFile (org.apache.maven.scm.ChangeFile)6 ArrayList (java.util.ArrayList)4 ChangeSet (org.apache.maven.scm.ChangeSet)4 ScmException (org.apache.maven.scm.ScmException)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 LinkedHashMap (java.util.LinkedHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 ScmResult (org.apache.maven.scm.ScmResult)1 BranchScmResult (org.apache.maven.scm.command.branch.BranchScmResult)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 DefaultLog (org.apache.maven.scm.log.DefaultLog)1