changeset 317:fc1b940bd4a6

treesum: when accepting treesum digest files put a line with its filename into the output
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 10 Mar 2025 10:25:57 +0100
parents 3f1f1c2e9e5f
children 0cc1e0de8fce
files cutils/treesum.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Mon Mar 10 10:25:20 2025 +0100
+++ b/cutils/treesum.py	Mon Mar 10 10:25:57 2025 +0100
@@ -804,6 +804,7 @@
                                     size=sz)
                                 return (errno.ESRCH, None, None, None)
                         # We got all required infos without errors
+                        self._writer.write_accept_treesum_file(fpath)
                         if self._size_only:
                             self._writer.write_size(opath, collector.size)
                         else:
@@ -1396,6 +1397,12 @@
             self.write(util.b(str(sz)))
         self.writeln(b"")
 
+    def write_accept_treesum_file(self, filename):
+        assert isinstance(filename, bytes)
+        self.write(b"ACCEPT-TREESUM (")
+        self.write(filename)
+        self.writeln(b")")
+
     def write_file_digest(self, algorithm, filename, digest,
                           use_base64=False, size=None):
         assert isinstance(filename, bytes)
@@ -1457,7 +1464,7 @@
 
     PATTERN0 = re.compile(br"\A[ \t]*\r?\n\Z")   # empty lines
     PATTERN1 = re.compile(br"\A(VERSION|FSENCODING|FLAGS|TIMESTAMP|ISOTIMESTAMP|CRC32)[ \t]*=[ \t]*([^ \t]+)[ \t]*\r?\n\Z")      # noqa: E501  line too long
-    PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH)[ \t]*\((.*)\)[ \t]*\r?\n\Z")                                       # noqa: E501  line too long
+    PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH|ACCEPT-TREESUM)[ \t]*\((.*)\)[ \t]*\r?\n\Z")                                       # noqa: E501  line too long
     PATTERN3 = re.compile(br"\ASIZE[ \t]*\((.*)\)([ \t]*=[ \t]*(\d+))?[ \t]*\r?\n\Z")                                               # noqa: E501  line too long
     PATTERN4 = re.compile(br"\A([A-Za-z0-9_-]+)[ \t]*\((.*)\)([ \t]*=[ \t]*([A-Za-z0-9=+/]+)?(,(\d+)?)?)?[ \t]*\r?\n\Z")              # noqa: E501  line too long
 
@@ -1589,6 +1596,8 @@
                     return (util.n(mo.group(1)), util.u(mo.group(2), "utf-8"))
                 elif mo.group(1) == b"ROOT":
                     return ("ROOT", mo.group(2))
+                elif mo.group(1) == b"ACCEPT-TREESUM":
+                    return ("ACCEPT-TREESUM", mo.group(2))
                 assert False, line
             else:
                 mo = self.PATTERN3.search(line)
@@ -1710,6 +1719,8 @@
                     fnmatch_filters.append(record[1])
                 elif record[0] in ("TIMESTAMP", "ISOTIMESTAMP"):
                     pass
+                elif record[0] == "ACCEPT-TREESUM":
+                    pass
                 elif record[0] == "CRC32":
                     pass
                     # in_block = False