[PATCH 2 of 5] run-tests: move esc match in its own function for better readability
Matt Mackall
mpm at selenic.com
Mon Oct 15 17:38:27 CDT 2012
On Fri, 2012-10-12 at 18:43 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1350059460 -7200
> # Node ID 6c31cb28b26af2f883892ed831373e27815d8941
> # Parent 02b74c548336c6bfb6f8c8506567826fc535131d
> run-tests: move esc match in its own function for better readability
>
> testing os.name == 'nt' before replace is just a little optimisation
^^^^^^^^^^^^^^^^^^^^^^^^^^
That's a synonym for "please reject this patch".
Given that
(x or y) and z
is different from
x or (y and z)
..it is NOT obvious that the old and new code are the same without
consulting Python's precedence/associativity rules. So it shouldn't be
snuck into a patch that's doing something different.
> +def escmatch(el, l):
> + el = el.decode('string-escape')
> + return el == l or os.name == 'nt' and el.replace('\r', '') == l
In fact, 'or' has higher precedence than 'and' in Python, so here we
have:
(el == l or os.name == 'nt') and el.replace('\r', '') == l
..which does not appear to be what's wanted.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list