diff --git a/tests/run-tests.py b/tests/run-tests.py
index 518dd70d1a6ed993e364256d7cfcdbdc0b876996_dGVzdHMvcnVuLXRlc3RzLnB5..b911cb80c671784ef86c051cc0cf72766e1b452d_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -454,6 +454,15 @@
     vlog("# Running", cmd)
     return run(cmd, options, replacements)
 
+needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
+escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub
+escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256))
+escapemap.update({'\\': '\\\\', '\r': r'\r'})
+def escapef(m):
+    return escapemap[m.group(0)]
+def stringescape(s):
+    return escapesub(escapef, s)
+
 def tsttest(test, options, replacements):
     t = open(test)
     out = []
@@ -545,7 +554,5 @@
 
             if el == lout: # perfect match (fast)
                 postout.append("  " + lout)
-            elif el and el.decode('string-escape') == l:
-                postout.append("  " + el)  # \-escape match
             elif (el and
                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or
@@ -550,5 +557,6 @@
             elif (el and
                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or
-                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout))):
-                postout.append("  " + el) # fallback regex/glob match
+                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout)) or
+                   el.endswith(" (esc)\n") and el.decode('string-escape') == l):
+                postout.append("  " + el) # fallback regex/glob/esc match
             else:
@@ -554,4 +562,6 @@
             else:
+                if needescape(lout):
+                    lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
                 postout.append("  " + lout) # let diff deal with it
 
         if lcmd:
diff --git a/tests/test-encoding-align.t b/tests/test-encoding-align.t
index 518dd70d1a6ed993e364256d7cfcdbdc0b876996_dGVzdHMvdGVzdC1lbmNvZGluZy1hbGlnbi50..b911cb80c671784ef86c051cc0cf72766e1b452d_dGVzdHMvdGVzdC1lbmNvZGluZy1hbGlnbi50 100644
--- a/tests/test-encoding-align.t
+++ b/tests/test-encoding-align.t
@@ -52,5 +52,5 @@
   
   options:
   
-   -s --opt1 \xe7\x9f\xad\xe5\x90\x8d          short width
+   -s --opt1 \xe7\x9f\xad\xe5\x90\x8d          short width (esc)
    -m --opt2 MIDDLE_       middle width
@@ -56,5 +56,5 @@
    -m --opt2 MIDDLE_       middle width
-   -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d  long width
+   -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d  long width (esc)
   
   use "hg -v help showoptlist" to show global options
 
@@ -96,5 +96,5 @@
 check alignment of user names in annotate
 
   $ hg annotate -u $M
-          \xe7\x9f\xad\xe5\x90\x8d: first line(2)
+          \xe7\x9f\xad\xe5\x90\x8d: first line(2) (esc)
        MIDDLE_: second line(2)
@@ -100,7 +100,7 @@
        MIDDLE_: second line(2)
-  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2)
+  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) (esc)
 
 check alignment of filenames in diffstat
 
   $ hg diff -c tip --stat
    MIDDLE_      |  1 +
@@ -102,12 +102,12 @@
 
 check alignment of filenames in diffstat
 
   $ hg diff -c tip --stat
    MIDDLE_      |  1 +
-   \xe7\x9f\xad\xe5\x90\x8d         |  1 +
-   \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d |  1 +
+   \xe7\x9f\xad\xe5\x90\x8d         |  1 + (esc)
+   \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d |  1 + (esc)
    3 files changed, 3 insertions(+), 0 deletions(-)
 
 add branches/tags
 
   $ hg branch $S
@@ -109,11 +109,11 @@
    3 files changed, 3 insertions(+), 0 deletions(-)
 
 add branches/tags
 
   $ hg branch $S
-  marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d
+  marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc)
   $ hg tag $S
   $ hg branch $M
   marked working directory as branch MIDDLE_
   $ hg tag $M
   $ hg branch $L
@@ -115,12 +115,12 @@
   $ hg tag $S
   $ hg branch $M
   marked working directory as branch MIDDLE_
   $ hg tag $M
   $ hg branch $L
-  marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d
+  marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
   $ hg tag $L
 
 check alignment of branches
 
   $ hg tags
   tip                                5:d745ff46155b
@@ -121,8 +121,8 @@
   $ hg tag $L
 
 check alignment of branches
 
   $ hg tags
   tip                                5:d745ff46155b
-  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d                       4:9259be597f19
+  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d                       4:9259be597f19 (esc)
   MIDDLE_                            3:b06c5b6def9e
@@ -128,7 +128,7 @@
   MIDDLE_                            3:b06c5b6def9e
-  \xe7\x9f\xad\xe5\x90\x8d                               2:64a70663cee8
+  \xe7\x9f\xad\xe5\x90\x8d                               2:64a70663cee8 (esc)
 
 check alignment of tags
 
   $ hg tags
   tip                                5:d745ff46155b
@@ -130,7 +130,7 @@
 
 check alignment of tags
 
   $ hg tags
   tip                                5:d745ff46155b
-  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d                       4:9259be597f19
+  \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d                       4:9259be597f19 (esc)
   MIDDLE_                            3:b06c5b6def9e
@@ -136,2 +136,2 @@
   MIDDLE_                            3:b06c5b6def9e
-  \xe7\x9f\xad\xe5\x90\x8d                               2:64a70663cee8
+  \xe7\x9f\xad\xe5\x90\x8d                               2:64a70663cee8 (esc)
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
index 518dd70d1a6ed993e364256d7cfcdbdc0b876996_dGVzdHMvdGVzdC1wYXRjaGJvbWIudA==..b911cb80c671784ef86c051cc0cf72766e1b452d_dGVzdHMvdGVzdC1wYXRjaGJvbWIudA== 100644
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -148,7 +148,7 @@
   $ hg email -m test.mbox -f quux -t foo -c bar -s test 0:tip \
   > --config extensions.progress= --config progress.assume-tty=1 \
   > --config progress.delay=0 --config progress.refresh=0
-  \rwriting [                                                                 ] 0/3\rwriting [                                                                 ] 0/3\r                                                                                \r\r                                                                                \r\rwriting [====================>                                            ] 1/3\rwriting [====================>                                            ] 1/3\r                                                                                \r\r                                                                                \r\rwriting [==========================================>                      ] 2/3\rwriting [==========================================>                      ] 2/3\r                                                                                \rThis patch series consists of 2 patches.
+  \rwriting [                                                                 ] 0/3\rwriting [                                                                 ] 0/3\r                                                                                \r\r                                                                                \r\rwriting [====================>                                            ] 1/3\rwriting [====================>                                            ] 1/3\r                                                                                \r\r                                                                                \r\rwriting [==========================================>                      ] 2/3\rwriting [==========================================>                      ] 2/3\r                                                                                \rThis patch series consists of 2 patches. (esc)
   
   
   Write the introductory message for the patch series.