[ 
https://issues.apache.org/jira/browse/SCM-539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17961979#comment-17961979
 ] 

ASF GitHub Bot commented on SCM-539:
------------------------------------

jira-importer commented on issue #750:
URL: https://github.com/apache/maven-scm/issues/750#issuecomment-2964622199

   **[Olivier 
Lamy](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=olamy)** 
commented
   
   rev 952815
   Thanks (please next time provide a patch using svn diff)
   




> Unparseable date with Mercurial SCM provider
> --------------------------------------------
>
>                 Key: SCM-539
>                 URL: https://issues.apache.org/jira/browse/SCM-539
>             Project: Maven SCM (Moved to GitHub Issues)
>          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
>            Assignee: Olivier Lamy
>            Priority: Blocker
>             Fix For: 1.4
>
>
> [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 was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to