[PATCH 2 of 5] run-tests: move esc match in its own function for better readability
Simon Heimberg
simohe at besonet.ch
Fri Oct 12 11:43:21 CDT 2012
# 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
diff -r 02b74c548336 -r 6c31cb28b26a tests/run-tests.py
--- a/tests/run-tests.py Fre Okt 12 18:30:50 2012 +0200
+++ b/tests/run-tests.py Fre Okt 12 18:31:00 2012 +0200
@@ -536,6 +536,10 @@
res += re.escape(c)
return rematch(res, l)
+def escmatch(el, l):
+ el = el.decode('string-escape')
+ return el == l or os.name == 'nt' and el.replace('\r', '') == l
+
def linematch(el, l):
if el == l: # perfect match (fast)
return True
@@ -543,10 +547,7 @@
return False
if el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
- el.endswith(" (esc)\n") and
- (el[:-7].decode('string-escape') + '\n' == l or
- el[:-7].decode('string-escape').replace('\r', '') +
- '\n' == l and os.name == 'nt')):
+ el.endswith(" (esc)\n") and escmatch(el[:-7] + '\n', l)
return True
return False
More information about the Mercurial-devel
mailing list