equal
deleted
inserted
replaced
495 |
495 |
496 # Bytes that break XML even in a CDATA block: control characters 0-31 |
496 # Bytes that break XML even in a CDATA block: control characters 0-31 |
497 # sans \t, \n and \r |
497 # sans \t, \n and \r |
498 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") |
498 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") |
499 |
499 |
|
500 # Match feature conditionalized output lines in the form, capturing the feature |
|
501 # list in group 2, and the preceeding line output in group 1: |
|
502 # |
|
503 # output..output (feature !)\n |
|
504 optline = re.compile(b'(.+) \((.+?) !\)\n$') |
|
505 |
500 def cdatasafe(data): |
506 def cdatasafe(data): |
501 """Make a string safe to include in a CDATA block. |
507 """Make a string safe to include in a CDATA block. |
502 |
508 |
503 Certain control characters are illegal in a CDATA block, and |
509 Certain control characters are illegal in a CDATA block, and |
504 there's no way to include a ]]> in a CDATA either. This function |
510 there's no way to include a ]]> in a CDATA either. This function |
1269 log('\ninfo, unknown linematch result: %r\n' % r) |
1275 log('\ninfo, unknown linematch result: %r\n' % r) |
1270 r = False |
1276 r = False |
1271 if r: |
1277 if r: |
1272 els.pop(i) |
1278 els.pop(i) |
1273 break |
1279 break |
1274 if el and el.endswith(b" (?)\n"): |
1280 if el: |
1275 optional.append(i) |
1281 if el.endswith(b" (?)\n"): |
|
1282 optional.append(i) |
|
1283 else: |
|
1284 m = optline.match(el) |
|
1285 if m: |
|
1286 conditions = [c for c in m.group(2).split(' ')] |
|
1287 |
|
1288 if self._hghave(conditions)[0]: |
|
1289 lout = el |
|
1290 else: |
|
1291 optional.append(i) |
|
1292 |
1276 i += 1 |
1293 i += 1 |
1277 |
1294 |
1278 if r: |
1295 if r: |
1279 if r == "retry": |
1296 if r == "retry": |
1280 continue |
1297 continue |
1296 break |
1313 break |
1297 else: |
1314 else: |
1298 # clean up any optional leftovers |
1315 # clean up any optional leftovers |
1299 while expected.get(pos, None): |
1316 while expected.get(pos, None): |
1300 el = expected[pos].pop(0) |
1317 el = expected[pos].pop(0) |
1301 if el and not el.endswith(b" (?)\n"): |
1318 if el: |
1302 break |
1319 if (not optline.match(el) |
|
1320 and not el.endswith(b" (?)\n")): |
|
1321 break |
1303 postout.append(b' ' + el) |
1322 postout.append(b' ' + el) |
1304 |
1323 |
1305 if lcmd: |
1324 if lcmd: |
1306 # Add on last return code. |
1325 # Add on last return code. |
1307 ret = int(lcmd.split()[1]) |
1326 ret = int(lcmd.split()[1]) |
1369 return True |
1388 return True |
1370 if el: |
1389 if el: |
1371 if el.endswith(b" (?)\n"): |
1390 if el.endswith(b" (?)\n"): |
1372 retry = "retry" |
1391 retry = "retry" |
1373 el = el[:-5] + b"\n" |
1392 el = el[:-5] + b"\n" |
|
1393 else: |
|
1394 m = optline.match(el) |
|
1395 if m: |
|
1396 el = m.group(1) + b"\n" |
|
1397 retry = "retry" |
|
1398 |
1374 if el.endswith(b" (esc)\n"): |
1399 if el.endswith(b" (esc)\n"): |
1375 if PYTHON3: |
1400 if PYTHON3: |
1376 el = el[:-7].decode('unicode_escape') + '\n' |
1401 el = el[:-7].decode('unicode_escape') + '\n' |
1377 el = el.encode('utf-8') |
1402 el = el.encode('utf-8') |
1378 else: |
1403 else: |