Unparseable date with Mercurial SCM provider
--------------------------------------------
Key: SCM-539
URL: http://jira.codehaus.org/browse/SCM-539
Project: Maven SCM
Issue Type: Bug
Components: maven-scm-provider-mercurial (hg)
Affects Versions: 1.4
Environment: OS: Ubuntu (probably all?)
Mercurial version: 1.3.1
Reporter: Peter Liljenberg
Priority: Blocker
[ERROR] skip ParseException: Unparseable date: " 0 Wed Oct 21 13:25:19 2009
+0200" during parsing date 0 Wed Oct 21 13:25:19 2009 +0200 with pattern EEE
MMM dd HH:mm:ss yyyy Z with Locale en
java.text.ParseException: Unparseable date: " 0 Wed Oct 21 13:25:19 2009 +0200"
at java.text.DateFormat.parse(DateFormat.java:337)
at
org.apache.maven.scm.util.AbstractConsumer.parseDate(AbstractConsumer.java:112)
at
org.apache.maven.scm.util.AbstractConsumer.parseDate(AbstractConsumer.java:68)
at
org.apache.maven.scm.provider.hg.command.blame.HgBlameConsumer.doConsume(HgBlameConsumer.java:52)
at
org.apache.maven.scm.provider.hg.command.HgConsumer.consumeLine(HgConsumer.java:131)
Problem seems to the extra spaces after the username.
Output from HG is:
Peter 0 Wed Oct 21 13:25:19 2009 +0200: package utils.jar;
A working line from the same HG repo:
Peter 1531 Wed Oct 21 13:25:19 2009 +0200: package utils.jar;
The extra spaces between username and revision is messing up the following code:
HgBlameConsumer:
{code:title=Bar.java|borderStyle=solid}
public void doConsume(final String trimmedLine) {
/* godin 0 Sun Jan 31 03:04:54 2010 +0300 */
String annotation = trimmedLine.substring(0, trimmedLine.indexOf(": "));
final String author = annotation.substring(0, annotation.indexOf(' '));
annotation = annotation.substring(annotation.indexOf(' ') + 1);
final String revision = annotation.substring(0, annotation.indexOf('
'));
annotation = annotation.substring(annotation.indexOf(' ') + 1);
final String dateStr = annotation.trim();
final Date dateTime = parseDate(dateStr, null, HG_TIMESTAMP_PATTERN,
null);
}
{code}
A simple fix for this would be to strip the **annotation** string (probably
after each stubstring call) like this:
{code:title=Bar.java|borderStyle=solid}
public void doConsume(final String trimmedLine) {
/* godin 0 Sun Jan 31 03:04:54 2010 +0300 */
String annotation = trimmedLine.substring(0, trimmedLine.indexOf(":
")).trim();
final String author = annotation.substring(0, annotation.indexOf(' '));
annotation = annotation.substring(annotation.indexOf(' ') + 1).trim();
final String revision = annotation.substring(0, annotation.indexOf('
'));
annotation = annotation.substring(annotation.indexOf(' ') + 1).trim();
final String dateStr = annotation;
final Date dateTime = parseDate(dateStr, null, HG_TIMESTAMP_PATTERN,
null);
}
{code}
I patched the code and it worked on our HG repo at least. Please consider
patching this....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira