mercurial/templatekw.py
changeset 28239 7279e0132347
parent 28178 96f2d50fb9f6
child 28270 650c9f69a744
--- a/mercurial/templatekw.py	Thu Feb 25 10:34:31 2016 +0100
+++ b/mercurial/templatekw.py	Sun Dec 27 20:21:37 2015 +0900
@@ -9,6 +9,7 @@
 
 from .node import hex, nullid
 from . import (
+    encoding,
     error,
     hbisect,
     patch,
@@ -257,7 +258,12 @@
 
 def showdescription(repo, ctx, templ, **args):
     """:desc: String. The text of the changeset description."""
-    return ctx.description().strip()
+    s = ctx.description()
+    if isinstance(s, encoding.localstr):
+        # try hard to preserve utf-8 bytes
+        return encoding.tolocal(encoding.fromlocal(s).strip())
+    else:
+        return s.strip()
 
 def showdiffstat(repo, ctx, templ, **args):
     """:diffstat: String. Statistics of changes with the following format: