Uploaded image for project: 'Maven SCM'
  1. Maven SCM
  2. SCM-539

Unparseable date with Mercurial SCM provider

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4
    • Labels:
      None
    • Environment:
      OS: Ubuntu (probably all?)
      Mercurial version: 1.3.1
    • Flags:
      Patch

      Description

      [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:

      Bar.java
       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);
      
          }
      

      A simple fix for this would be to strip the *annotation* string (probably after each stubstring call) like this:

      Bar.java
        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);
      
          }
      

      I patched the code and it worked on our HG repo at least. Please consider patching this....

        Attachments

          Activity

            People

            • Assignee:
              olamy Olivier Lamy
              Reporter:
              pliljenberg@gmail.com Peter Liljenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: