diff --git a/plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgChangesetViewer.java b/plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgChangesetViewer.java
index e2f63d39c0..9168033ee1 100644
--- a/plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgChangesetViewer.java
+++ b/plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgChangesetViewer.java
@@ -50,7 +50,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+import java.util.Date;
import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
@@ -69,12 +76,16 @@ public class HgChangesetViewer implements ChangesetViewer
/** Field description */
public static final String TEMPLATE =
- "{rev}:{short}{author|escape}{desc|escape}{date|isodatesec}";
+ "{rev}:{short}{author|escape}{desc|escape}{date|isodatesec}\n";
/** the logger for HgChangesetViewer */
private static final Logger logger =
LoggerFactory.getLogger(HgChangesetViewer.class);
+ /** Field description */
+ public static final Pattern REGEX_DATE =
+ Pattern.compile("([^<]+)");
+
//~--- constructors ---------------------------------------------------------
/**
@@ -94,8 +105,6 @@ public class HgChangesetViewer implements ChangesetViewer
//~--- get methods ----------------------------------------------------------
/**
- * TODO unmarshall date
- *
*
* @param startId
* @param max
@@ -118,12 +127,8 @@ public class HgChangesetViewer implements ChangesetViewer
if (result.isSuccessfull())
{
- StringBuilder changesetLog = new StringBuilder("");
-
- changesetLog.append(result.getOutput());
- changesetLog.append("");
-
- StringReader reader = new StringReader(changesetLog.toString());
+ StringReader reader =
+ new StringReader(getFixedOutput(result.getOutput()));
Unmarshaller unmarshaller = handler.createChangesetUnmarshaller();
Changesets cs = (Changesets) unmarshaller.unmarshal(reader);
@@ -143,6 +148,10 @@ public class HgChangesetViewer implements ChangesetViewer
result.getReturnCode(), result.getOutput());
}
}
+ catch (ParseException ex)
+ {
+ logger.error("could not parse changeset dates", ex);
+ }
catch (IOException ex)
{
logger.error("could not load changesets", ex);
@@ -173,6 +182,44 @@ public class HgChangesetViewer implements ChangesetViewer
return getChangesets(ID_TIP, max);
}
+ /**
+ * Method description
+ *
+ *
+ * @param output
+ *
+ * @return
+ *
+ * @throws ParseException
+ */
+ private String getFixedOutput(String output) throws ParseException
+ {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+ StringBuilder changesetLog = new StringBuilder("");
+ StringTokenizer st = new StringTokenizer(output, "\n");
+
+ while (st.hasMoreElements())
+ {
+ String line = st.nextToken();
+ Matcher m = REGEX_DATE.matcher(line);
+
+ if (m.find())
+ {
+ String dateString = m.group(1);
+ Date date = sdf.parse(dateString);
+
+ line = m.replaceAll(
+ "".concat(Util.formatDate(date)).concat(""));
+ }
+
+ changesetLog.append(line);
+ }
+
+ changesetLog.append("");
+
+ return changesetLog.toString();
+ }
+
/**
* Method description
*