Example #1
0
  /**
   * Process the current input line in the GET_HEADER state. The author, date, and the revision of
   * the entry are gathered. Note, Subversion does not have per-file revisions, instead, the entire
   * repository is given a single revision number, which is used for the revision number of each
   * file.
   *
   * @param line A line of text from the svn log output
   */
  private void processGetHeader(String line) {
    if (!HEADER_REG_EXP.match(line)) {
      // The header line is not found. Intentionally do nothing.
      return;
    }

    currentRevision = getRevision(HEADER_REG_EXP.getParen(REVISION_GROUP));

    currentChange = new SvnChangeSet();

    currentChange.setAuthor(HEADER_REG_EXP.getParen(AUTHOR_GROUP));

    currentChange.setDate(getDate(HEADER_REG_EXP.getParen(DATE_GROUP)));

    currentChange.setRevision(currentRevision);

    status = GET_FILE;
  }
Example #2
0
  /**
   * Process the current input line in the GET_COMMENT state. This state gathers all of the comments
   * that are part of a log entry.
   *
   * @param line a line of text from the svn log output
   */
  private void processGetComment(String line) {
    if (line.equals(COMMENT_END_TOKEN)) {
      currentChange.setComment(currentComment.toString());

      entries.add(currentChange);

      status = GET_HEADER;
    } else {
      currentComment.append(line).append('\n');
    }
  }
Example #3
0
  /**
   * 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) {
    if (FILE_PATTERN.match(line)) {
      final String fileinfo = FILE_PATTERN.getParen(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);
        if (ORIG_FILE_PATTERN.match(origFileInfo)) {
          // if original file is present, we must extract the affected one from the beginning
          name = fileinfo.substring(0, n);
          originalName = ORIG_FILE_PATTERN.getParen(1);
          originalRev = ORIG_FILE_PATTERN.getParen(2);
        }
      }
      final String actionStr = FILE_PATTERN.getParen(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)) {
        action = ScmFileStatus.UPDATED; // == REPLACED in svn terms
      } else {
        action = ScmFileStatus.UNKNOWN;
      }
      System.out.println(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;
    }
  }