Exemplo n.º 1
0
 /**
  * Gets the svn revision, from the svn log revision output.
  *
  * @param revisionOutput
  * @return the svn revision
  */
 private String getRevision(final String revisionOutput) {
   if (REVISION_REG_EXP1.match(revisionOutput)) {
     return REVISION_REG_EXP1.getParen(1);
   } else if (REVISION_REG_EXP2.match(revisionOutput)) {
     return REVISION_REG_EXP2.getParen(1);
   } else {
     throw new IllegalOutputException(revisionOutput);
   }
 }
Exemplo n.º 2
0
  /**
   * Converts the date time stamp from the svn output into a date object.
   *
   * @param dateOutput The date output from an svn log command.
   * @return A date representing the time stamp of the log entry.
   */
  private Date getDate(final String dateOutput) {
    if (!DATE_REG_EXP.match(dateOutput)) {
      throw new IllegalOutputException(dateOutput);
    }

    final StringBuilder date = new StringBuilder();
    date.append(DATE_REG_EXP.getParen(1));
    date.append(" GMT");
    date.append(DATE_REG_EXP.getParen(2));
    date.append(DATE_REG_EXP.getParen(3));
    date.append(':');
    date.append(DATE_REG_EXP.getParen(4));

    return parseDate(date.toString(), userDateFormat, SVN_TIMESTAMP_PATTERN);
  }
  public void consumeLine(String line) {
    if (lineRegexp.match(line)) {
      String revision = lineRegexp.getParen(1);
      // SCM-613
      String author = lineRegexp.getParen(2).toLowerCase();
      String dateTimeStr = lineRegexp.getParen(3);

      Date dateTime = parseDate(dateTimeStr, null, CLEARCASE_TIMESTAMP_PATTERN);
      lines.add(new BlameLine(dateTime, revision, author));

      if (getLogger().isDebugEnabled()) {
        getLogger().debug(author + " " + dateTimeStr);
      }
    }
  }
  /** {@inheritDoc} */
  public void consumeLine(String line) {
    if (lineRegexp.match(line)) {
      String revision = lineRegexp.getParen(1).trim();

      lines.add(new BlameLine(null, revision, null));
    }
  }
Exemplo n.º 5
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;
    }
  }
Exemplo n.º 6
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;
  }
Exemplo n.º 7
0
  /**
   * A parameter expansion algorithm, designed to replace strings delimited by percent signs '%'
   * with a value supplied by a Map object.
   *
   * <p>NOTE: This function only replaces one particular parameter, the <code>%noticeid%</code>
   * parameter.
   *
   * @param input the input string
   * @param paramMap a map that will supply the substitution values
   * @return a {@link java.lang.String} object.
   */
  public static String expandNotifParms(final String input, final Map<String, String> paramMap) {
    String expanded = input;

    if (m_expandRE.match(expanded)) {
      String key = m_expandRE.getParen(1);
      Assert.isTrue("noticeid".equals(key));
      String replace = paramMap.get(key);
      if (replace != null) {
        expanded = m_expandRE.subst(expanded, replace);
      }
    }
    return expanded;
  }