diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-07-08 22:50:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-08 22:50:30 -0500 |
| commit | 45b63a4297db01c3961faa4052e28bbff95c55e6 (patch) | |
| tree | e6e010b4400bf2123b92cf3b644e0e242a3c4f9a | |
| parent | 5f9a70ec9f6bae58842b36f80f8f125617fa6071 (diff) | |
| parent | 7c8a6d978bb47827eeef15448ca95f82af32c381 (diff) | |
| download | rust-45b63a4297db01c3961faa4052e28bbff95c55e6.tar.gz rust-45b63a4297db01c3961faa4052e28bbff95c55e6.zip | |
Rollup merge of #143606 - lambdageek:configure-write-last-key, r=Kobzol
configure.py: Write last key in each section The loop that writes the keys in each section of bootstrap.toml accumulates all the commented lines before a given key and emits them when it reaches the next key in the section. This ends up dropping lines accumulated for the last key Fixes rust-lang/rust#143605
| -rwxr-xr-x | src/bootstrap/configure.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index c077555b906..b05a5cc8b81 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -739,19 +739,29 @@ def configure_file(sections, top_level_keys, targets, config): def write_uncommented(target, f): + """Writes each block in 'target' that is not composed entirely of comments to 'f'. + + A block is a sequence of non-empty lines separated by empty lines. + """ block = [] - is_comment = True + + def flush(last): + # If the block is entirely made of comments, ignore it + entire_block_comments = all(ln.startswith("#") or ln == "" for ln in block) + if not entire_block_comments and len(block) > 0: + for line in block: + f.write(line + "\n") + # Required to output a newline before the start of a new section + if last: + f.write("\n") + block.clear() for line in target: block.append(line) if len(line) == 0: - if not is_comment: - for ln in block: - f.write(ln + "\n") - block = [] - is_comment = True - continue - is_comment = is_comment and line.startswith("#") + flush(last=False) + + flush(last=True) return f |
