D3879: tests: move handling of None "el" out of linematch()

2018-07-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5a20b6090a6e: tests: move handling of None "el" 
out of linematch() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3879?vs=9426&id=9450

REVISION DETAIL
  https://phab.mercurial-scm.org/D3879

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1482,8 +1482,9 @@
 
 optional = []
 for i, el in enumerate(els):
-
-r = self.linematch(el, lout)
+r = False
+if el:
+r = self.linematch(el, lout)
 if isinstance(r, str):
 if r == '-glob':
 lout = ''.join(el.rsplit(' (glob)', 1))
@@ -1606,41 +1607,40 @@
 return TTest.rematch(res, l)
 
 def linematch(self, el, l):
-retry = False
 if el == l: # perfect match (fast)
 return True
-if el:
-if el.endswith(b" (?)\n"):
-retry = "retry"
-el = el[:-5] + b"\n"
+retry = False
+if el.endswith(b" (?)\n"):
+retry = "retry"
+el = el[:-5] + b"\n"
+else:
+m = optline.match(el)
+if m:
+conditions = [c for c in m.group(2).split(b' ')]
+
+el = m.group(1) + b"\n"
+if not self._iftest(conditions):
+retry = "retry"# Not required by listed features
+
+if el.endswith(b" (esc)\n"):
+if PYTHON3:
+el = el[:-7].decode('unicode_escape') + '\n'
+el = el.encode('utf-8')
 else:
-m = optline.match(el)
-if m:
-conditions = [c for c in m.group(2).split(b' ')]
-
-el = m.group(1) + b"\n"
-if not self._iftest(conditions):
-retry = "retry"# Not required by listed features
-
-if el.endswith(b" (esc)\n"):
-if PYTHON3:
-el = el[:-7].decode('unicode_escape') + '\n'
-el = el.encode('utf-8')
-else:
-el = el[:-7].decode('string-escape') + '\n'
-if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+el = el[:-7].decode('string-escape') + '\n'
+if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+return True
+if el.endswith(b" (re)\n"):
+return TTest.rematch(el[:-6], l) or retry
+if el.endswith(b" (glob)\n"):
+# ignore '(glob)' added to l by 'replacements'
+if l.endswith(b" (glob)\n"):
+l = l[:-8] + b"\n"
+return TTest.globmatch(el[:-8], l) or retry
+if os.altsep:
+_l = l.replace(b'\\', b'/')
+if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
 return True
-if el.endswith(b" (re)\n"):
-return TTest.rematch(el[:-6], l) or retry
-if el.endswith(b" (glob)\n"):
-# ignore '(glob)' added to l by 'replacements'
-if l.endswith(b" (glob)\n"):
-l = l[:-8] + b"\n"
-return TTest.globmatch(el[:-8], l) or retry
-if os.altsep:
-_l = l.replace(b'\\', b'/')
-if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
-return True
 return retry
 
 @staticmethod



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3879: tests: move handling of None "el" out of linematch()

2018-07-03 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 9426.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3879?vs=9421&id=9426

REVISION DETAIL
  https://phab.mercurial-scm.org/D3879

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1482,8 +1482,9 @@
 
 optional = []
 for i, el in enumerate(els):
-
-r = self.linematch(el, lout)
+r = False
+if el:
+r = self.linematch(el, lout)
 if isinstance(r, str):
 if r == '-glob':
 lout = ''.join(el.rsplit(' (glob)', 1))
@@ -1606,41 +1607,40 @@
 return TTest.rematch(res, l)
 
 def linematch(self, el, l):
-retry = False
 if el == l: # perfect match (fast)
 return True
-if el:
-if el.endswith(b" (?)\n"):
-retry = "retry"
-el = el[:-5] + b"\n"
+retry = False
+if el.endswith(b" (?)\n"):
+retry = "retry"
+el = el[:-5] + b"\n"
+else:
+m = optline.match(el)
+if m:
+conditions = [c for c in m.group(2).split(b' ')]
+
+el = m.group(1) + b"\n"
+if not self._iftest(conditions):
+retry = "retry"# Not required by listed features
+
+if el.endswith(b" (esc)\n"):
+if PYTHON3:
+el = el[:-7].decode('unicode_escape') + '\n'
+el = el.encode('utf-8')
 else:
-m = optline.match(el)
-if m:
-conditions = [c for c in m.group(2).split(b' ')]
-
-el = m.group(1) + b"\n"
-if not self._iftest(conditions):
-retry = "retry"# Not required by listed features
-
-if el.endswith(b" (esc)\n"):
-if PYTHON3:
-el = el[:-7].decode('unicode_escape') + '\n'
-el = el.encode('utf-8')
-else:
-el = el[:-7].decode('string-escape') + '\n'
-if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+el = el[:-7].decode('string-escape') + '\n'
+if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+return True
+if el.endswith(b" (re)\n"):
+return TTest.rematch(el[:-6], l) or retry
+if el.endswith(b" (glob)\n"):
+# ignore '(glob)' added to l by 'replacements'
+if l.endswith(b" (glob)\n"):
+l = l[:-8] + b"\n"
+return TTest.globmatch(el[:-8], l) or retry
+if os.altsep:
+_l = l.replace(b'\\', b'/')
+if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
 return True
-if el.endswith(b" (re)\n"):
-return TTest.rematch(el[:-6], l) or retry
-if el.endswith(b" (glob)\n"):
-# ignore '(glob)' added to l by 'replacements'
-if l.endswith(b" (glob)\n"):
-l = l[:-8] + b"\n"
-return TTest.globmatch(el[:-8], l) or retry
-if os.altsep:
-_l = l.replace(b'\\', b'/')
-if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
-return True
 return retry
 
 @staticmethod



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3879: tests: move handling of None "el" out of linematch()

2018-07-03 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It just seems odd for linematch() to know what None means.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3879

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1482,8 +1482,9 @@
 
 optional = []
 for i, el in enumerate(els):
-
-r = self.linematch(el, lout)
+r = False
+if el:
+r = self.linematch(el, lout)
 if isinstance(r, str):
 if r == '-glob':
 lout = ''.join(el.rsplit(' (glob)', 1))
@@ -1606,41 +1607,40 @@
 return TTest.rematch(res, l)
 
 def linematch(self, el, l):
-retry = False
 if el == l: # perfect match (fast)
 return True
-if el:
-if el.endswith(b" (?)\n"):
-retry = "retry"
-el = el[:-5] + b"\n"
+retry = False
+if el.endswith(b" (?)\n"):
+retry = "retry"
+el = el[:-5] + b"\n"
+else:
+m = optline.match(el)
+if m:
+conditions = [c for c in m.group(2).split(b' ')]
+
+el = m.group(1) + b"\n"
+if not self._iftest(conditions):
+retry = "retry"# Not required by listed features
+
+if el.endswith(b" (esc)\n"):
+if PYTHON3:
+el = el[:-7].decode('unicode_escape') + '\n'
+el = el.encode('utf-8')
 else:
-m = optline.match(el)
-if m:
-conditions = [c for c in m.group(2).split(b' ')]
-
-el = m.group(1) + b"\n"
-if not self._iftest(conditions):
-retry = "retry"# Not required by listed features
-
-if el.endswith(b" (esc)\n"):
-if PYTHON3:
-el = el[:-7].decode('unicode_escape') + '\n'
-el = el.encode('utf-8')
-else:
-el = el[:-7].decode('string-escape') + '\n'
-if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+el = el[:-7].decode('string-escape') + '\n'
+if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
+return True
+if el.endswith(b" (re)\n"):
+return TTest.rematch(el[:-6], l) or retry
+if el.endswith(b" (glob)\n"):
+# ignore '(glob)' added to l by 'replacements'
+if l.endswith(b" (glob)\n"):
+l = l[:-8] + b"\n"
+return TTest.globmatch(el[:-8], l) or retry
+if os.altsep:
+_l = l.replace(b'\\', b'/')
+if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
 return True
-if el.endswith(b" (re)\n"):
-return TTest.rematch(el[:-6], l) or retry
-if el.endswith(b" (glob)\n"):
-# ignore '(glob)' added to l by 'replacements'
-if l.endswith(b" (glob)\n"):
-l = l[:-8] + b"\n"
-return TTest.globmatch(el[:-8], l) or retry
-if os.altsep:
-_l = l.replace(b'\\', b'/')
-if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
-return True
 return retry
 
 @staticmethod



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel