|
@@ -37,35 +37,35 @@ class ChangeLogParser { |
|
|
private static final int GET_PREVIOUS_REV = 5; |
|
|
private static final int GET_PREVIOUS_REV = 5; |
|
|
|
|
|
|
|
|
/** input format for dates read in from cvs log */ |
|
|
/** input format for dates read in from cvs log */ |
|
|
private static final SimpleDateFormat c_inputDate |
|
|
|
|
|
|
|
|
private static final SimpleDateFormat INPUT_DATE |
|
|
= new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
|
|
= new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
static { |
|
|
static { |
|
|
TimeZone utc = TimeZone.getTimeZone("UTC"); |
|
|
TimeZone utc = TimeZone.getTimeZone("UTC"); |
|
|
c_inputDate.setTimeZone(utc); |
|
|
|
|
|
|
|
|
INPUT_DATE.setTimeZone(utc); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//The following is data used while processing stdout of CVS command |
|
|
//The following is data used while processing stdout of CVS command |
|
|
private String m_file; |
|
|
|
|
|
private String m_date; |
|
|
|
|
|
private String m_author; |
|
|
|
|
|
private String m_comment; |
|
|
|
|
|
private String m_revision; |
|
|
|
|
|
private String m_previousRevision; |
|
|
|
|
|
|
|
|
private String file; |
|
|
|
|
|
private String date; |
|
|
|
|
|
private String author; |
|
|
|
|
|
private String comment; |
|
|
|
|
|
private String revision; |
|
|
|
|
|
private String previousRevision; |
|
|
|
|
|
|
|
|
private int m_status = GET_FILE; |
|
|
|
|
|
|
|
|
private int status = GET_FILE; |
|
|
|
|
|
|
|
|
/** rcs entries */ |
|
|
/** rcs entries */ |
|
|
private final Hashtable m_entries = new Hashtable(); |
|
|
|
|
|
|
|
|
private final Hashtable entries = new Hashtable(); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Get a list of rcs entries as an array. |
|
|
* Get a list of rcs entries as an array. |
|
|
* |
|
|
* |
|
|
* @return a list of rcs entries as an array |
|
|
* @return a list of rcs entries as an array |
|
|
*/ |
|
|
*/ |
|
|
CVSEntry[] getEntrySetAsArray() { |
|
|
|
|
|
final CVSEntry[] array = new CVSEntry[ m_entries.size() ]; |
|
|
|
|
|
Enumeration e = m_entries.elements(); |
|
|
|
|
|
|
|
|
public CVSEntry[] getEntrySetAsArray() { |
|
|
|
|
|
final CVSEntry[] array = new CVSEntry[ entries.size() ]; |
|
|
|
|
|
Enumeration e = entries.elements(); |
|
|
int i = 0; |
|
|
int i = 0; |
|
|
while (e.hasMoreElements()) { |
|
|
while (e.hasMoreElements()) { |
|
|
array[i++] = (CVSEntry) e.nextElement(); |
|
|
array[i++] = (CVSEntry) e.nextElement(); |
|
@@ -76,9 +76,10 @@ class ChangeLogParser { |
|
|
/** |
|
|
/** |
|
|
* Receive notification about the process writing |
|
|
* Receive notification about the process writing |
|
|
* to standard output. |
|
|
* to standard output. |
|
|
|
|
|
* @param line the line to process |
|
|
*/ |
|
|
*/ |
|
|
public void stdout(final String line) { |
|
|
public void stdout(final String line) { |
|
|
switch(m_status) { |
|
|
|
|
|
|
|
|
switch(status) { |
|
|
case GET_FILE: |
|
|
case GET_FILE: |
|
|
// make sure attributes are reset when |
|
|
// make sure attributes are reset when |
|
|
// working on a 'new' file. |
|
|
// working on a 'new' file. |
|
@@ -100,6 +101,10 @@ class ChangeLogParser { |
|
|
case GET_PREVIOUS_REV: |
|
|
case GET_PREVIOUS_REV: |
|
|
processGetPreviousRevision(line); |
|
|
processGetPreviousRevision(line); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
// Do nothing |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -110,114 +115,115 @@ class ChangeLogParser { |
|
|
*/ |
|
|
*/ |
|
|
private void processComment(final String line) { |
|
|
private void processComment(final String line) { |
|
|
final String lineSeparator = System.getProperty("line.separator"); |
|
|
final String lineSeparator = System.getProperty("line.separator"); |
|
|
if (line.equals("=============================================================================")) { |
|
|
|
|
|
|
|
|
if (line.equals( |
|
|
|
|
|
"=============================================================================")) { |
|
|
//We have ended changelog for that particular file |
|
|
//We have ended changelog for that particular file |
|
|
//so we can save it |
|
|
//so we can save it |
|
|
final int end |
|
|
final int end |
|
|
= m_comment.length() - lineSeparator.length(); //was -1 |
|
|
|
|
|
m_comment = m_comment.substring(0, end); |
|
|
|
|
|
|
|
|
= comment.length() - lineSeparator.length(); //was -1 |
|
|
|
|
|
comment = comment.substring(0, end); |
|
|
saveEntry(); |
|
|
saveEntry(); |
|
|
m_status = GET_FILE; |
|
|
|
|
|
|
|
|
status = GET_FILE; |
|
|
} else if (line.equals("----------------------------")) { |
|
|
} else if (line.equals("----------------------------")) { |
|
|
final int end |
|
|
final int end |
|
|
= m_comment.length() - lineSeparator.length(); //was -1 |
|
|
|
|
|
m_comment = m_comment.substring(0, end); |
|
|
|
|
|
m_status = GET_PREVIOUS_REV; |
|
|
|
|
|
|
|
|
= comment.length() - lineSeparator.length(); //was -1 |
|
|
|
|
|
comment = comment.substring(0, end); |
|
|
|
|
|
status = GET_PREVIOUS_REV; |
|
|
} else { |
|
|
} else { |
|
|
m_comment += line + lineSeparator; |
|
|
|
|
|
|
|
|
comment += line + lineSeparator; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Process a line while in "GET_FILE" state. |
|
|
* Process a line while in "GET_FILE" state. |
|
|
* |
|
|
* |
|
|
* @param line the line |
|
|
|
|
|
|
|
|
* @param line the line to process |
|
|
*/ |
|
|
*/ |
|
|
private void processFile(final String line) { |
|
|
private void processFile(final String line) { |
|
|
if (line.startsWith("Working file:")) { |
|
|
if (line.startsWith("Working file:")) { |
|
|
m_file = line.substring(14, line.length()); |
|
|
|
|
|
m_status = GET_REVISION; |
|
|
|
|
|
|
|
|
file = line.substring(14, line.length()); |
|
|
|
|
|
status = GET_REVISION; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Process a line while in "REVISION" state. |
|
|
* Process a line while in "REVISION" state. |
|
|
* |
|
|
* |
|
|
* @param line the line |
|
|
|
|
|
|
|
|
* @param line the line to process |
|
|
*/ |
|
|
*/ |
|
|
private void processRevision(final String line) { |
|
|
private void processRevision(final String line) { |
|
|
if (line.startsWith("revision")) { |
|
|
if (line.startsWith("revision")) { |
|
|
m_revision = line.substring(9); |
|
|
|
|
|
m_status = GET_DATE; |
|
|
|
|
|
|
|
|
revision = line.substring(9); |
|
|
|
|
|
status = GET_DATE; |
|
|
} else if (line.startsWith("======")) { |
|
|
} else if (line.startsWith("======")) { |
|
|
//There was no revisions in this changelog |
|
|
//There was no revisions in this changelog |
|
|
//entry so lets move unto next file |
|
|
//entry so lets move unto next file |
|
|
m_status = GET_FILE; |
|
|
|
|
|
|
|
|
status = GET_FILE; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Process a line while in "DATE" state. |
|
|
* Process a line while in "DATE" state. |
|
|
* |
|
|
* |
|
|
* @param line the line |
|
|
|
|
|
|
|
|
* @param line the line to process |
|
|
*/ |
|
|
*/ |
|
|
private void processDate(final String line) { |
|
|
private void processDate(final String line) { |
|
|
if (line.startsWith("date:")) { |
|
|
if (line.startsWith("date:")) { |
|
|
m_date = line.substring(6, 25); |
|
|
|
|
|
|
|
|
date = line.substring(6, 25); |
|
|
String lineData = line.substring(line.indexOf(";") + 1); |
|
|
String lineData = line.substring(line.indexOf(";") + 1); |
|
|
m_author = lineData.substring(10, lineData.indexOf(";")); |
|
|
|
|
|
|
|
|
author = lineData.substring(10, lineData.indexOf(";")); |
|
|
|
|
|
|
|
|
m_status = GET_COMMENT; |
|
|
|
|
|
|
|
|
status = GET_COMMENT; |
|
|
|
|
|
|
|
|
//Reset comment to empty here as we can accumulate multiple lines |
|
|
//Reset comment to empty here as we can accumulate multiple lines |
|
|
//in the processComment method |
|
|
//in the processComment method |
|
|
m_comment = ""; |
|
|
|
|
|
|
|
|
comment = ""; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Process a line while in "GET_PREVIOUS_REVISION" state. |
|
|
* Process a line while in "GET_PREVIOUS_REVISION" state. |
|
|
* |
|
|
* |
|
|
* @param line the line |
|
|
|
|
|
|
|
|
* @param line the line to process |
|
|
*/ |
|
|
*/ |
|
|
private void processGetPreviousRevision(final String line) { |
|
|
private void processGetPreviousRevision(final String line) { |
|
|
if (!line.startsWith("revision")) { |
|
|
if (!line.startsWith("revision")) { |
|
|
throw new IllegalStateException("Unexpected line from CVS: " |
|
|
throw new IllegalStateException("Unexpected line from CVS: " |
|
|
+ line); |
|
|
+ line); |
|
|
} |
|
|
} |
|
|
m_previousRevision = line.substring(9); |
|
|
|
|
|
|
|
|
previousRevision = line.substring(9); |
|
|
|
|
|
|
|
|
saveEntry(); |
|
|
saveEntry(); |
|
|
|
|
|
|
|
|
m_revision = m_previousRevision; |
|
|
|
|
|
m_status = GET_DATE; |
|
|
|
|
|
|
|
|
revision = previousRevision; |
|
|
|
|
|
status = GET_DATE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Utility method that saves the current entry. |
|
|
* Utility method that saves the current entry. |
|
|
*/ |
|
|
*/ |
|
|
private void saveEntry() { |
|
|
private void saveEntry() { |
|
|
final String entryKey = m_date + m_author + m_comment; |
|
|
|
|
|
|
|
|
final String entryKey = date + author + comment; |
|
|
CVSEntry entry; |
|
|
CVSEntry entry; |
|
|
if (!m_entries.containsKey(entryKey)) { |
|
|
|
|
|
entry = new CVSEntry(parseDate(m_date), m_author, m_comment); |
|
|
|
|
|
m_entries.put(entryKey, entry); |
|
|
|
|
|
|
|
|
if (!entries.containsKey(entryKey)) { |
|
|
|
|
|
entry = new CVSEntry(parseDate(date), author, comment); |
|
|
|
|
|
entries.put(entryKey, entry); |
|
|
} else { |
|
|
} else { |
|
|
entry = (CVSEntry) m_entries.get(entryKey); |
|
|
|
|
|
|
|
|
entry = (CVSEntry) entries.get(entryKey); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
entry.addFile(m_file, m_revision, m_previousRevision); |
|
|
|
|
|
|
|
|
entry.addFile(file, revision, previousRevision); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Parse date out from expected format. |
|
|
* Parse date out from expected format. |
|
|
* |
|
|
* |
|
|
* @param date the string holding dat |
|
|
|
|
|
|
|
|
* @param date the string holding date |
|
|
* @return the date object or null if unknown date format |
|
|
* @return the date object or null if unknown date format |
|
|
*/ |
|
|
*/ |
|
|
private Date parseDate(final String date) { |
|
|
private Date parseDate(final String date) { |
|
|
try { |
|
|
try { |
|
|
return c_inputDate.parse(date); |
|
|
|
|
|
|
|
|
return INPUT_DATE.parse(date); |
|
|
} catch (ParseException e) { |
|
|
} catch (ParseException e) { |
|
|
//final String message = REZ.getString( "changelog.bat-date.error", date ); |
|
|
//final String message = REZ.getString( "changelog.bat-date.error", date ); |
|
|
//getContext().error( message ); |
|
|
//getContext().error( message ); |
|
@@ -226,15 +232,14 @@ class ChangeLogParser { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* reset all internal attributes except status. |
|
|
|
|
|
|
|
|
* Reset all internal attributes except status. |
|
|
*/ |
|
|
*/ |
|
|
private void reset() { |
|
|
|
|
|
m_file = null; |
|
|
|
|
|
m_date = null; |
|
|
|
|
|
m_author = null; |
|
|
|
|
|
m_comment = null; |
|
|
|
|
|
m_revision = null; |
|
|
|
|
|
m_previousRevision = null; |
|
|
|
|
|
|
|
|
public void reset() { |
|
|
|
|
|
this.file = null; |
|
|
|
|
|
this.date = null; |
|
|
|
|
|
this.author = null; |
|
|
|
|
|
this.comment = null; |
|
|
|
|
|
this.revision = null; |
|
|
|
|
|
this.previousRevision = null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |