Mercurial > hgrepos > Python > apps > py-cutils
changeset 161:df927ada9a37
In directory digests: include the octet-length of the checksums also
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 07 Jan 2025 19:20:32 +0100 |
| parents | 432fe71300d3 |
| children | 29dd5528174c |
| files | cutils/treesum.py |
| diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/cutils/treesum.py Tue Jan 07 12:55:55 2025 +0100 +++ b/cutils/treesum.py Tue Jan 07 19:20:32 2025 +0100 @@ -321,7 +321,8 @@ linkdgst.update(b"%d:%s," % (len(linktgt), linktgt)) dir_dgst = algorithm[0]() dir_dgst.update(b"1:L,") - dir_dgst.update(linkdgst.digest()) + dir_dgst.update( + b"%d:%s," % (len(linkdgst.digest()), linkdgst.digest())) outfp.write( format_bsd_line( algorithm[1], @@ -344,7 +345,9 @@ dir_dgst.update(b"1:S,%d:%s," % (len(fso.fsname), fso.fsname)) # no mtime and no mode for symlinks - dir_dgst.update(linkdgst.digest()) + dir_dgst.update( + b"%d:%s," + % (len(linkdgst.digest()), linkdgst.digest())) opath = "/".join(top) + "/" + fso.name if top else fso.name outfp.write( format_bsd_line( @@ -357,7 +360,8 @@ # fetch from dir_digests dgst = dir_digests[top + (fso.name,)] dir_dgst.update(b"1:d,%d:%s," % (len(fso.fsname), fso.fsname)) - dir_dgst.update(dgst) + dir_dgst.update( + b"%d:%s," % (len(dgst), dgst)) if with_metadata_full_mode: modestr = normalized_mode_str(fso.stat.st_mode) if not isinstance(modestr, bytes): @@ -391,7 +395,7 @@ dir_dgst.update(b"4:mode,%d:%s," % (len(modestr), modestr)) dgst = digest.compute_digest_file( algorithm[0], fso.path, use_mmap=use_mmap) - dir_dgst.update(dgst) + dir_dgst.update(b"%d:%s," % (len(dgst), dgst)) opath = "/".join(top) + "/" + fso.name if top else fso.name outfp.write( format_bsd_line(
