Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 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 | 49ecfff4f319 |
comparison
equal
deleted
inserted
replaced
| 316:3f1f1c2e9e5f | 317:fc1b940bd4a6 |
|---|---|
| 802 None, | 802 None, |
| 803 use_base64=self._use_base64, | 803 use_base64=self._use_base64, |
| 804 size=sz) | 804 size=sz) |
| 805 return (errno.ESRCH, None, None, None) | 805 return (errno.ESRCH, None, None, None) |
| 806 # We got all required infos without errors | 806 # We got all required infos without errors |
| 807 self._writer.write_accept_treesum_file(fpath) | |
| 807 if self._size_only: | 808 if self._size_only: |
| 808 self._writer.write_size(opath, collector.size) | 809 self._writer.write_size(opath, collector.size) |
| 809 else: | 810 else: |
| 810 self._writer.write_file_digest( | 811 self._writer.write_file_digest( |
| 811 collector.algorithm, opath, collector.digest, | 812 collector.algorithm, opath, collector.digest, |
| 1394 if sz is not None: | 1395 if sz is not None: |
| 1395 self.write(b" = ") | 1396 self.write(b" = ") |
| 1396 self.write(util.b(str(sz))) | 1397 self.write(util.b(str(sz))) |
| 1397 self.writeln(b"") | 1398 self.writeln(b"") |
| 1398 | 1399 |
| 1400 def write_accept_treesum_file(self, filename): | |
| 1401 assert isinstance(filename, bytes) | |
| 1402 self.write(b"ACCEPT-TREESUM (") | |
| 1403 self.write(filename) | |
| 1404 self.writeln(b")") | |
| 1405 | |
| 1399 def write_file_digest(self, algorithm, filename, digest, | 1406 def write_file_digest(self, algorithm, filename, digest, |
| 1400 use_base64=False, size=None): | 1407 use_base64=False, size=None): |
| 1401 assert isinstance(filename, bytes) | 1408 assert isinstance(filename, bytes) |
| 1402 if digest is not None: | 1409 if digest is not None: |
| 1403 digest = (base64.b64encode(digest) | 1410 digest = (base64.b64encode(digest) |
| 1455 | 1462 |
| 1456 """ | 1463 """ |
| 1457 | 1464 |
| 1458 PATTERN0 = re.compile(br"\A[ \t]*\r?\n\Z") # empty lines | 1465 PATTERN0 = re.compile(br"\A[ \t]*\r?\n\Z") # empty lines |
| 1459 PATTERN1 = re.compile(br"\A(VERSION|FSENCODING|FLAGS|TIMESTAMP|ISOTIMESTAMP|CRC32)[ \t]*=[ \t]*([^ \t]+)[ \t]*\r?\n\Z") # noqa: E501 line too long | 1466 PATTERN1 = re.compile(br"\A(VERSION|FSENCODING|FLAGS|TIMESTAMP|ISOTIMESTAMP|CRC32)[ \t]*=[ \t]*([^ \t]+)[ \t]*\r?\n\Z") # noqa: E501 line too long |
| 1460 PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH)[ \t]*\((.*)\)[ \t]*\r?\n\Z") # noqa: E501 line too long | 1467 PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH|ACCEPT-TREESUM)[ \t]*\((.*)\)[ \t]*\r?\n\Z") # noqa: E501 line too long |
| 1461 PATTERN3 = re.compile(br"\ASIZE[ \t]*\((.*)\)([ \t]*=[ \t]*(\d+))?[ \t]*\r?\n\Z") # noqa: E501 line too long | 1468 PATTERN3 = re.compile(br"\ASIZE[ \t]*\((.*)\)([ \t]*=[ \t]*(\d+))?[ \t]*\r?\n\Z") # noqa: E501 line too long |
| 1462 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 | 1469 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 |
| 1463 | 1470 |
| 1464 def __init__(self, _fp, _filename, _own_fp): | 1471 def __init__(self, _fp, _filename, _own_fp): |
| 1465 self._fp = _fp | 1472 self._fp = _fp |
| 1587 if mo.group(1) in (b"COMMENT", b"ERROR", b"GENERATOR", | 1594 if mo.group(1) in (b"COMMENT", b"ERROR", b"GENERATOR", |
| 1588 b"FNMATCH"): | 1595 b"FNMATCH"): |
| 1589 return (util.n(mo.group(1)), util.u(mo.group(2), "utf-8")) | 1596 return (util.n(mo.group(1)), util.u(mo.group(2), "utf-8")) |
| 1590 elif mo.group(1) == b"ROOT": | 1597 elif mo.group(1) == b"ROOT": |
| 1591 return ("ROOT", mo.group(2)) | 1598 return ("ROOT", mo.group(2)) |
| 1599 elif mo.group(1) == b"ACCEPT-TREESUM": | |
| 1600 return ("ACCEPT-TREESUM", mo.group(2)) | |
| 1592 assert False, line | 1601 assert False, line |
| 1593 else: | 1602 else: |
| 1594 mo = self.PATTERN3.search(line) | 1603 mo = self.PATTERN3.search(line) |
| 1595 if mo: | 1604 if mo: |
| 1596 self._update_crc(line) | 1605 self._update_crc(line) |
| 1708 errors.add(record[1]) | 1717 errors.add(record[1]) |
| 1709 elif record[0] == "FNMATCH": | 1718 elif record[0] == "FNMATCH": |
| 1710 fnmatch_filters.append(record[1]) | 1719 fnmatch_filters.append(record[1]) |
| 1711 elif record[0] in ("TIMESTAMP", "ISOTIMESTAMP"): | 1720 elif record[0] in ("TIMESTAMP", "ISOTIMESTAMP"): |
| 1712 pass | 1721 pass |
| 1722 elif record[0] == "ACCEPT-TREESUM": | |
| 1723 pass | |
| 1713 elif record[0] == "CRC32": | 1724 elif record[0] == "CRC32": |
| 1714 pass | 1725 pass |
| 1715 # in_block = False | 1726 # in_block = False |
| 1716 else: | 1727 else: |
| 1717 if not in_block: | 1728 if not in_block: |
