changeset 134:d2c303695fb8

Put a file version number into the output. While there change the output order: ROOT() not directly before the digests.
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 02 Jan 2025 23:03:20 +0100
parents cf4fb9a33f94
children dbf27681a1f6
files cutils/treesum.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Thu Jan 02 21:03:43 2025 +0100
+++ b/cutils/treesum.py	Thu Jan 02 23:03:20 2025 +0100
@@ -142,7 +142,7 @@
     :param outfp: a *binary* file with a "write()" and a "flush()" method
 
     """
-    outfp.write(format_bsd_line("ROOT", None, root, False))
+    outfp.write(format_bsd_line("VERSION", "1", None, False))
     outfp.flush()
 
     # Note given non-default flags that are relevant for directory traversal
@@ -153,12 +153,17 @@
         flags.append("follow-directory-symlinks")
     if flags:
         outfp.write(format_bsd_line("FLAGS", ",".join(flags), None, False))
+        outfp.flush()
 
     # Write execution timestamps in POSIX epoch and ISO format
     ts = time.time()
     outfp.write(format_bsd_line("TIMESTAMP", ts, None, False))
     ts = (datetime.datetime.utcfromtimestamp(ts)).isoformat("T")
     outfp.write(format_bsd_line("ISOTIMESTAMP", ts, None, False))
+    outfp.flush()
+
+    outfp.write(format_bsd_line("ROOT", None, root, False))
+    outfp.flush()
 
     dir_digests = {}
 
@@ -227,7 +232,7 @@
     if digestname == b"TIMESTAMP":
         assert filename is None
         return b"TIMESTAMP = %d%s" % (value, ls)
-    if digestname in (b"ISOTIMESTAMP", b"FLAGS"):
+    if digestname in (b"ISOTIMESTAMP", b"FLAGS", b"VERSION"):
         assert filename is None
         if not isinstance(value, bytes):
             value = value.encode("ascii")