Patchwork [2,of,2] run-tests: assign value to ESCAPEMAP - dict.update do not return self

login
register
mail settings
Submitter Mads Kiilerich
Date May 25, 2014, 11:48 a.m.
Message ID <665481b33700b726fb48.1401018517@localhost.localdomain>
Download mbox | patch
Permalink /patch/4861/
State Accepted
Headers show

Comments

Mads Kiilerich - May 25, 2014, 11:48 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1401018462 -7200
#      Sun May 25 13:47:42 2014 +0200
# Node ID 665481b33700b726fb48fd7bc930239499f2ac65
# Parent  c5e55adeb37b9e1bcaec2e9fc3745f47d568e3d1
run-tests: assign value to ESCAPEMAP - dict.update do not return self

a36cc85a5b7b did more than what the description said and introduced a bug.
Mads Kiilerich - May 25, 2014, 11:55 a.m.
On 05/25/2014 01:48 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1401018462 -7200
> #      Sun May 25 13:47:42 2014 +0200
> # Node ID 665481b33700b726fb48fd7bc930239499f2ac65
> # Parent  c5e55adeb37b9e1bcaec2e9fc3745f47d568e3d1
> run-tests: assign value to ESCAPEMAP - dict.update do not return self
>
> a36cc85a5b7b did more than what the description said and introduced a bug.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -675,8 +675,8 @@ class TTest(Test):
>       NEEDESCAPE = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
>   
>       ESCAPESUB = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub

related to a36cc85a5b7b: I think the convention of using upper case for 
"global" simple "static consts" is fine ... and it might also extend to 
static class members. But these two are just functions (that happens to 
be defined in a clever/ugly way). I do not think the upper case 
convention should apply to them.

/Mads

> -    ESCAPEMAP = dict((chr(i), r'\x%02x' % i) for i in range(256)).update(
> -                     {'\\': '\\\\', '\r': r'\r'})
> +    ESCAPEMAP = dict((chr(i), r'\x%02x' % i) for i in range(256))
> +    ESCAPEMAP.update({'\\': '\\\\', '\r': r'\r'})
>   
>       @property
>       def refpath(self):
Augie Fackler - May 26, 2014, 4:07 p.m.
On Sun, May 25, 2014 at 01:48:37PM +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1401018462 -7200
> #      Sun May 25 13:47:42 2014 +0200
> # Node ID 665481b33700b726fb48fd7bc930239499f2ac65
> # Parent  c5e55adeb37b9e1bcaec2e9fc3745f47d568e3d1
> run-tests: assign value to ESCAPEMAP - dict.update do not return self

Looks good, queued.

>
> a36cc85a5b7b did more than what the description said and introduced a bug.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -675,8 +675,8 @@ class TTest(Test):
>      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)).update(
> -                     {'\\': '\\\\', '\r': r'\r'})
> +    ESCAPEMAP = dict((chr(i), r'\x%02x' % i) for i in range(256))
> +    ESCAPEMAP.update({'\\': '\\\\', '\r': r'\r'})
>
>      @property
>      def refpath(self):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -675,8 +675,8 @@  class TTest(Test):
     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)).update(
-                     {'\\': '\\\\', '\r': r'\r'})
+    ESCAPEMAP = dict((chr(i), r'\x%02x' % i) for i in range(256))
+    ESCAPEMAP.update({'\\': '\\\\', '\r': r'\r'})
 
     @property
     def refpath(self):