view tests/filtertraceback.py @ 53040:cdd7bf612c7b stable tip

bundle-spec: properly format boolean parameter (issue6960) This was breaking automatic clone bundle generation. This changeset fixes it and add a test to catch it in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 11 Mar 2025 02:29:42 +0100
parents 4f9a3347bfb4
children
line wrap: on
line source

#!/usr/bin/env python3

# Filters traceback lines from stdin.


import io
import sys

# Prevent \r from being inserted on Windows.
sys.stdout = io.TextIOWrapper(
    sys.stdout.buffer,
    sys.stdout.encoding,
    sys.stdout.errors,
    newline="\n",
    line_buffering=sys.stdout.line_buffering,
)

in_tb = False

for line in sys.stdin:
    do_print = not in_tb
    if line.startswith('Traceback '):
        in_tb = True
    elif not line.startswith(' '):
        in_tb = False
        do_print = True
    if do_print:
        print(line, end='')