equal
deleted
inserted
replaced
1357 i = 0 |
1357 i = 0 |
1358 optional = [] |
1358 optional = [] |
1359 while i < len(els): |
1359 while i < len(els): |
1360 el = els[i] |
1360 el = els[i] |
1361 |
1361 |
1362 r = TTest.linematch(el, lout) |
1362 r = self.linematch(el, lout) |
1363 if isinstance(r, str): |
1363 if isinstance(r, str): |
1364 if r == '+glob': |
1364 if r == '+glob': |
1365 lout = el[:-1] + ' (glob)\n' |
1365 lout = el[:-1] + ' (glob)\n' |
1366 r = '' # Warn only this line. |
1366 r = '' # Warn only this line. |
1367 elif r == '-glob': |
1367 elif r == '-glob': |
1383 else: |
1383 else: |
1384 m = optline.match(el) |
1384 m = optline.match(el) |
1385 if m: |
1385 if m: |
1386 conditions = [c for c in m.group(2).split(' ')] |
1386 conditions = [c for c in m.group(2).split(' ')] |
1387 |
1387 |
1388 if self._hghave(conditions)[0]: |
1388 if not self._hghave(conditions)[0]: |
1389 lout = el |
|
1390 else: |
|
1391 optional.append(i) |
1389 optional.append(i) |
1392 |
1390 |
1393 i += 1 |
1391 i += 1 |
1394 |
1392 |
1395 if r: |
1393 if r: |
1414 else: |
1412 else: |
1415 # clean up any optional leftovers |
1413 # clean up any optional leftovers |
1416 while expected.get(pos, None): |
1414 while expected.get(pos, None): |
1417 el = expected[pos].pop(0) |
1415 el = expected[pos].pop(0) |
1418 if el: |
1416 if el: |
1419 if (not optline.match(el) |
1417 if not el.endswith(b" (?)\n"): |
1420 and not el.endswith(b" (?)\n")): |
1418 m = optline.match(el) |
1421 break |
1419 if m: |
|
1420 conditions = [c for c in m.group(2).split(' ')] |
|
1421 |
|
1422 if self._hghave(conditions)[0]: |
|
1423 # Don't append as optional line |
|
1424 continue |
|
1425 else: |
|
1426 break |
1422 postout.append(b' ' + el) |
1427 postout.append(b' ' + el) |
1423 |
1428 |
1424 if lcmd: |
1429 if lcmd: |
1425 # Add on last return code. |
1430 # Add on last return code. |
1426 ret = int(lcmd.split()[1]) |
1431 ret = int(lcmd.split()[1]) |
1479 res += b'[/\\\\]' |
1484 res += b'[/\\\\]' |
1480 else: |
1485 else: |
1481 res += re.escape(c) |
1486 res += re.escape(c) |
1482 return TTest.rematch(res, l) |
1487 return TTest.rematch(res, l) |
1483 |
1488 |
1484 @staticmethod |
1489 def linematch(self, el, l): |
1485 def linematch(el, l): |
|
1486 retry = False |
1490 retry = False |
1487 if el == l: # perfect match (fast) |
1491 if el == l: # perfect match (fast) |
1488 return True |
1492 return True |
1489 if el: |
1493 if el: |
1490 if el.endswith(b" (?)\n"): |
1494 if el.endswith(b" (?)\n"): |
1491 retry = "retry" |
1495 retry = "retry" |
1492 el = el[:-5] + b"\n" |
1496 el = el[:-5] + b"\n" |
1493 else: |
1497 else: |
1494 m = optline.match(el) |
1498 m = optline.match(el) |
1495 if m: |
1499 if m: |
|
1500 conditions = [c for c in m.group(2).split(' ')] |
|
1501 |
1496 el = m.group(1) + b"\n" |
1502 el = m.group(1) + b"\n" |
1497 retry = "retry" |
1503 if not self._hghave(conditions)[0]: |
|
1504 retry = "retry" # Not required by listed features |
1498 |
1505 |
1499 if el.endswith(b" (esc)\n"): |
1506 if el.endswith(b" (esc)\n"): |
1500 if PYTHON3: |
1507 if PYTHON3: |
1501 el = el[:-7].decode('unicode_escape') + '\n' |
1508 el = el[:-7].decode('unicode_escape') + '\n' |
1502 el = el.encode('utf-8') |
1509 el = el.encode('utf-8') |