Patchwork [2,of,3] revset: handle error of string unescaping

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 10, 2015, 3:10 p.m.
Message ID <6cafa7cb11d94c3e3eb7.1441897858@mimosa>
Download mbox | patch
Permalink /patch/10464/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 10, 2015, 3:10 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1441895395 -32400
#      Thu Sep 10 23:29:55 2015 +0900
# Node ID 6cafa7cb11d94c3e3eb77aaa68288ce5255b231a
# Parent  04afdd74ed1642a951baa8e7bb9af3c6cffb1950
revset: handle error of string unescaping

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -244,7 +244,7 @@  def tokenize(program, lookup=None, symin
                 c = program[pos]
                 decode = lambda x: x
             else:
-                decode = lambda x: x.decode('string-escape')
+                decode = parser.unescapestr
             pos += 1
             s = pos
             while pos < l: # find closing quote
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -353,6 +353,9 @@  quoting needed
   $ log 'date('
   hg: parse error at 5: not a prefix: end
   [255]
+  $ log 'date("\xy")'
+  hg: parse error: invalid \x escape
+  [255]
   $ log 'date(tip)'
   abort: invalid date: 'tip'
   [255]