##// END OF EJS Templates
templatekw: workaround for utf-8 round-trip of {desc}...
Yuya Nishihara -
r28239:7279e013 default
parent child Browse files
Show More
@@ -9,6 +9,7 b' from __future__ import absolute_import'
9
9
10 from .node import hex, nullid
10 from .node import hex, nullid
11 from . import (
11 from . import (
12 encoding,
12 error,
13 error,
13 hbisect,
14 hbisect,
14 patch,
15 patch,
@@ -257,7 +258,12 b' def showdate(repo, ctx, templ, **args):'
257
258
258 def showdescription(repo, ctx, templ, **args):
259 def showdescription(repo, ctx, templ, **args):
259 """:desc: String. The text of the changeset description."""
260 """:desc: String. The text of the changeset description."""
260 return ctx.description().strip()
261 s = ctx.description()
262 if isinstance(s, encoding.localstr):
263 # try hard to preserve utf-8 bytes
264 return encoding.tolocal(encoding.fromlocal(s).strip())
265 else:
266 return s.strip()
261
267
262 def showdiffstat(repo, ctx, templ, **args):
268 def showdiffstat(repo, ctx, templ, **args):
263 """:diffstat: String. Statistics of changes with the following format:
269 """:diffstat: String. Statistics of changes with the following format:
@@ -3556,12 +3556,14 b' Set up repository for non-ascii encoding'
3556 > open('utf-8', 'w').write('\xc3\xa9')
3556 > open('utf-8', 'w').write('\xc3\xa9')
3557 > EOF
3557 > EOF
3558 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
3558 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
3559 $ HGENCODING=utf-8 hg ci -qAm 'non-ascii branch' utf-8
3559 $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8
3560
3560
3561 json filter should try round-trip conversion to utf-8:
3561 json filter should try round-trip conversion to utf-8:
3562
3562
3563 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
3563 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
3564 "\u00e9"
3564 "\u00e9"
3565 $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0
3566 "non-ascii branch: \u00e9"
3565
3567
3566 json filter takes input as utf-8b:
3568 json filter takes input as utf-8b:
3567
3569
General Comments 0
You need to be logged in to leave comments. Login now