public void consumeLine()

in maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java [82:134]


    public void consumeLine(String line) {
        if (line.startsWith(INDEX_TOKEN)) {
            // start a new file
            currentFile = line.substring(INDEX_TOKEN.length() + HASH_ID_LEN + 1);

            changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED));

            currentDifference = new StringBuilder();

            differences.put(currentFile, currentDifference);

            patch.append(line).append("\n");

            return;
        }

        if (currentFile == null) {
            if (logger.isWarnEnabled()) {
                logger.warn("Unparseable line: '" + line + "'");
            }
            patch.append(line).append("\n");
            return;
        }

        if (line.startsWith(FILE_SEPARATOR_TOKEN)) {
            // skip
            patch.append(line).append("\n");
        } else if (line.startsWith(START_REVISION_TOKEN)) {
            // skip, though could parse to verify filename, start revision
            patch.append(line).append("\n");
        } else if (line.startsWith(END_REVISION_TOKEN)) {
            // skip, though could parse to verify filename, end revision
            patch.append(line).append("\n");
        } else if (line.startsWith(ADDED_LINE_TOKEN)
                || line.startsWith(REMOVED_LINE_TOKEN)
                || line.startsWith(UNCHANGED_LINE_TOKEN)
                || line.startsWith(CHANGE_SEPARATOR_TOKEN)
                || line.equals(NO_NEWLINE_TOKEN)) {
            // add to buffer
            currentDifference.append(line).append("\n");
            patch.append(line).append("\n");
        } else {
            // TODO: handle property differences

            if (logger.isWarnEnabled()) {
                logger.warn("Unparseable line: '" + line + "'");
            }
            patch.append(line).append("\n");
            // skip to next file
            currentFile = null;
            currentDifference = null;
        }
    }