Search in sources :

Example 11 with ScmFileStatus

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

the class JazzListChangesetConsumer method processChangesLine.

private void processChangesLine(String line) {
    // Process the changes line, eg:
    // ---c- (1170) \GPDB\GPDBEAR\pom.xml
    // ---c- (1171) \GPDB\GPDBResources\pom.xml
    // ---c- (1167) \GPDB\GPDBWeb\pom.xml
    // ---c- (1165) \GPDB\pom.xml
    Matcher matcher = CHANGES_PATTERN.matcher(line);
    if (matcher.find()) {
        ChangeSet currentChangeSet = entries.get(currentChangeSetIndex);
        // Not used.
        String changeFlags = matcher.group(1);
        String fileAlias = matcher.group(2);
        String file = matcher.group(3);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("  Parsing Changes Line : " + line);
            getLogger().debug("    changeFlags    : " + changeFlags + " Translated to : " + parseFileChangeState(changeFlags));
            getLogger().debug("    filetAlias     : " + fileAlias);
            getLogger().debug("    file           : " + file);
        }
        ChangeFile changeFile = new ChangeFile(file);
        ScmFileStatus status = parseFileChangeState(changeFlags);
        changeFile.setAction(status);
        currentChangeSet.getFiles().add(changeFile);
    }
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) Matcher(java.util.regex.Matcher) ChangeFile(org.apache.maven.scm.ChangeFile) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 12 with ScmFileStatus

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

the class JazzStatusConsumer method extractChangedFile.

private void extractChangedFile(String line) {
    String flag = line.trim().substring(0, 2);
    String filePath = line.trim().substring(3).trim();
    ScmFileStatus status = ScmFileStatus.UNKNOWN;
    if (STATUS_CMD_ADD_FLAG.equals(flag)) {
        status = ScmFileStatus.ADDED;
    }
    if (STATUS_CMD_CHANGE_FLAG.equals(flag)) {
        status = ScmFileStatus.MODIFIED;
    }
    if (STATUS_CMD_DELETE_FLAG.equals(flag)) {
        status = ScmFileStatus.DELETED;
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(" Extracted filePath  : '" + filePath + "'");
        getLogger().debug(" Extracted     flag  : '" + flag + "'");
        getLogger().debug(" Extracted   status  : '" + status + "'");
    }
    fChangedFiles.add(new ScmFile(filePath, status));
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) ScmFile(org.apache.maven.scm.ScmFile)

Example 13 with ScmFileStatus

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

the class JazzUpdateConsumer method extractUpdatedFile.

private void extractUpdatedFile(String line) {
    String filePath = "";
    String flag = line.trim().substring(0, 3);
    ScmFileStatus status = ScmFileStatus.UNKNOWN;
    if (UPDATE_CMD_ADD_FLAG.equals(flag)) {
        status = ScmFileStatus.ADDED;
        filePath = line.trim().substring(4);
    }
    if (UPDATE_CMD_CHANGE_FLAG.equals(flag)) {
        status = ScmFileStatus.UPDATED;
        filePath = line.trim().substring(4);
    }
    if (UPDATE_CMD_DELETE_FLAG.equals(flag)) {
        status = ScmFileStatus.DELETED;
        filePath = line.trim().substring(4);
    }
    // be marked as deleted. (see if this is the case in RTC 3.0)
    if (UPDATE_CMD_MOVED_FLAG.equals(flag)) {
        status = ScmFileStatus.ADDED;
        String pattern = "^" + UPDATE_CMD_MOVED_FLAG + "\\s(.*)\\s\\(moved\\sfrom\\s.*$";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(line.trim());
        if (m.find()) {
            filePath = m.group(1);
        }
    }
    fUpdatedFiles.add(new ScmFile(filePath, status));
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ScmFile(org.apache.maven.scm.ScmFile)

Example 14 with ScmFileStatus

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

the class SvnCheckOutConsumer method parseLine.

/**
 * {@inheritDoc}
 */
protected void parseLine(String line) {
    String statusString = line.substring(0, 1);
    String file = line.substring(3).trim();
    // [SCM-368]
    if (file.startsWith(getWorkingDirectory().getAbsolutePath())) {
        file = StringUtils.substring(file, getWorkingDirectory().getAbsolutePath().length() + 1);
    }
    ScmFileStatus status;
    if (line.startsWith(CHECKED_OUT_REVISION_TOKEN)) {
        String revisionString = line.substring(CHECKED_OUT_REVISION_TOKEN.length() + 1, line.length() - 1);
        revision = parseInt(revisionString);
        return;
    } else if (statusString.equals("A")) {
        status = ScmFileStatus.ADDED;
    } else if (statusString.equals("U")) {
        status = ScmFileStatus.UPDATED;
    } else {
        return;
    }
    addFile(new ScmFile(file, status));
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) ScmFile(org.apache.maven.scm.ScmFile)

Example 15 with ScmFileStatus

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

the class SvnMkdirConsumer method consumeLine.

/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (StringUtils.isBlank(line)) {
        return;
    }
    String statusString = line.substring(0, 1);
    ScmFileStatus status;
    if (line.startsWith(COMMITTED_REVISION_TOKEN)) {
        String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1);
        revision = Integer.parseInt(revisionString);
        return;
    } else if (statusString.equals("A")) {
        String file = line.substring(3);
        status = ScmFileStatus.ADDED;
        createdDirs.add(new ScmFile(file, status));
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("Unknown line: '" + line + "'");
        }
        return;
    }
}
Also used : ScmFileStatus(org.apache.maven.scm.ScmFileStatus) ScmFile(org.apache.maven.scm.ScmFile)

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