changeset 11766:a65ea28269ef

Merge with stable
author Patrick Mezard <pmezard@gmail.com>
date Sun, 08 Aug 2010 22:29:39 +0200
parents 16723af520b0 (current diff) aff419e260f9 (diff)
children 9b771b4ce2f3
files tests/test-hgweb-commands tests/test-hgweb-commands.out
diffstat 3 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatefilters.py	Sat Aug 07 16:13:53 2010 -0300
+++ b/mercurial/templatefilters.py	Sun Aug 08 22:29:39 2010 +0200
@@ -156,9 +156,10 @@
     elif isinstance(obj, int) or isinstance(obj, float):
         return str(obj)
     elif isinstance(obj, str):
-        return '"%s"' % jsonescape(obj)
+        u = unicode(obj, encoding.encoding, 'replace')
+        return '"%s"' % jsonescape(u).encode('utf-8')
     elif isinstance(obj, unicode):
-        return json(obj.encode('utf-8'))
+        return '"%s"' % jsonescape(obj).encode('utf-8')
     elif hasattr(obj, 'keys'):
         out = []
         for k, v in obj.iteritems():
--- a/tests/test-hgweb-commands	Sat Aug 07 16:13:53 2010 -0300
+++ b/tests/test-hgweb-commands	Sun Aug 08 22:29:39 2010 +0200
@@ -60,5 +60,19 @@
 echo % Static files
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/static/style.css'
 
+echo % Stop and restart with HGENCODING=cp932
+"$TESTDIR/killdaemons.py"
+HGENCODING=cp932 hg serve --config server.uncompressed=False -n test \
+    -p $HGPORT -d --pid-file=hg.pid -E errors.log
+cat hg.pid >> $DAEMON_PIDS
+
+# commit message with Japanese Kanji 'Noh', which ends with '\x5c'
+echo foo >> foo
+HGENCODING=cp932 hg ci -m `python -c 'print("\x94\x5c")'`
+
+echo % Graph json escape of multibyte character
+"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \
+    | grep '^var data ='
+
 echo % ERRORS ENCOUNTERED
 cat errors.log
--- a/tests/test-hgweb-commands.out	Sat Aug 07 16:13:53 2010 -0300
+++ b/tests/test-hgweb-commands.out	Sun Aug 08 22:29:39 2010 +0200
@@ -982,4 +982,7 @@
 	position: relative;
 	top: -1px;
 }
+% Stop and restart with HGENCODING=cp932
+% Graph json escape of multibyte character
+var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "能", "test", "1970-01-01", ["stable", true], ["tip"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"]]];
 % ERRORS ENCOUNTERED