From 3ba4919dc3eb52c735d21b7ab41aa42757e96995 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Fri, 4 Dec 2026 09:07:15 +0100 Subject: [PATCH 1/2] refactor: archive collector, GitTree and run_git for generate and migrate Groundwork for `tfmgr generate` and `tfmgr migrate` (WP4), with no change in what the checks report: - generate.collect_archive() gathers the template descriptions, atlas labels and transform targets that check_archive used to collect inline; templates.tsv and the TF801/TF803 checks now share it with the coming generators. - validate.archive.renames_problems() checks a root renames table from its text, given exists/installed callbacks, so a migration plan can check a simulated Archive. check_renames() wraps it. - io.run_git() runs git without a shell and keeps its output binary. - tree.GitTree reads a template from a commit without checking it out, under the same rules as DirectoryTree (only annex symlinks count, submodules and other symlinks are left out, annexed content is never read). check_archive() gives identical issues on master and on this branch for the Archive superdataset (all 30 templates installed). Co-Authored-By: Claude Opus 5.5 --- CHANGES.rst | 4 ++ tfmanager/generate.py | 45 ++++++++++++++ tfmanager/io.py | 25 ++++++++ tfmanager/tests/conftest.py | 17 ++++++ tfmanager/tests/test_archive.py | 40 +++++++++++++ tfmanager/tests/test_tree.py | 81 ++++++++++++++++++++++++- tfmanager/tree.py | 99 +++++++++++++++++++++++++++++++ tfmanager/validate/archive.py | 101 ++++++++++++++++---------------- 8 files changed, 360 insertions(+), 52 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a676842..0d4f67a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,10 @@ Unreleased ========== * Python 3.13 or newer, following `SPEC 0 `__ (tested on 3.13 to 3.15). +* New internals for ``tfmgr generate`` and ``tfmgr migrate``: ``GitTree`` reads a template + from a git commit without checking it out, ``collect_archive`` gathers what the + Archive's files and checks need from its templates, and ``renames_problems`` checks a + root renames table from its text. The checks report the same issues as before. 26.0.0rc4 (December 3, 2026) ============================ diff --git a/tfmanager/generate.py b/tfmanager/generate.py index d0baf20..7706cea 100644 --- a/tfmanager/generate.py +++ b/tfmanager/generate.py @@ -12,7 +12,13 @@ from __future__ import annotations +import json +from collections.abc import Iterable +from dataclasses import dataclass, field + +from .naming import parse from .tables import NA, Table, dump_json, json_cell, write_tsv +from .tree import Tree, visible #: atlases.tsv column -> atlas-