Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 375:7044c2900890
FIX: Convert the ultimate parse errors for a .treesum file into a real ValueError.
Do not assert such important runtime errors.
BUGS: Should be a dedicated exception type.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 05 May 2025 09:21:55 +0200 |
| parents | bfe1160fbfd3 |
| children | 6b327893a9c3 |
comparison
equal
deleted
inserted
replaced
| 374:c19a21180a8f | 375:7044c2900890 |
|---|---|
| 1868 size = None | 1868 size = None |
| 1869 return (algo_name, mo.group(2), digest, size) | 1869 return (algo_name, mo.group(2), digest, size) |
| 1870 else: | 1870 else: |
| 1871 return (algo_name, mo.group(2), None, None) | 1871 return (algo_name, mo.group(2), None, None) |
| 1872 else: | 1872 else: |
| 1873 assert False, line | 1873 raise ValueError( |
| 1874 "Cannot parse line: %r" % (line,)) | |
| 1874 return line | 1875 return line |
| 1875 | 1876 |
| 1876 def _get_next_line(self): | 1877 def _get_next_line(self): |
| 1877 line = self._fp.readline(4096) # along PATH_MAX on Linux | 1878 line = self._fp.readline(4096) # along PATH_MAX on Linux |
| 1878 if line: | 1879 if line: |
| 1930 fnmatch_filters = [] | 1931 fnmatch_filters = [] |
| 1931 in_block = False | 1932 in_block = False |
| 1932 block_no = 0 | 1933 block_no = 0 |
| 1933 for record in reader: | 1934 for record in reader: |
| 1934 if record[0] == "VERSION": | 1935 if record[0] == "VERSION": |
| 1935 assert record[1] == "1" | 1936 if record[1] != "1": |
| 1937 raise ValueError( | |
| 1938 "VERSION not yet handled: %r" % (record[1],)) | |
| 1936 # start a new block | 1939 # start a new block |
| 1937 in_block = True | 1940 in_block = True |
| 1938 block_no += 1 | 1941 block_no += 1 |
| 1939 root = flags = algorithm = digest = size = None | 1942 root = flags = algorithm = digest = size = None |
| 1940 comments = [] | 1943 comments = [] |
