comparison mercurial/dirstatemap.py @ 48052:d07d38ef6362

dirstate: Appease pytype test-check-pytype.t was failing since 98c0408324e6: File "/home/simon/projects/hg/mercurial/dirstatemap.py", line 572, in addfile: unsupported operand type(s) for &: 'size: None' and 'rangemask: int' [unsupported-operands] No attribute '__and__' on 'size: None' or '__rand__' on 'rangemask: int' File "/home/simon/projects/hg/mercurial/dirstatemap.py", line 573, in addfile: unsupported operand type(s) for &: 'mtime: None' and 'rangemask: int' [unsupported-operands] No attribute '__and__' on 'mtime: None' or '__rand__' on 'rangemask: int' `None` is the default value of the `size` and `mtime` parameters of the `addfile` method. However, the relevant lines are only used in a code path where those defaults are never used. These `size` and `mtime` are passed to `DirstateItem.new_normal` which (in the C implementation) calls `dirstate_item_new_normal` which uses: PyArg_ParseTuple(args, "iii", &mode, &size, &mtime) So `None` values would cause an exception to be raised anyway. The new `assert`s only move that exception earlier, and informs pytype that we expect `None` to never happen in this code path. Differential Revision: https://phab.mercurial-scm.org/D11500
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 28 Sep 2021 13:43:14 +0200
parents 98c0408324e6
children cd13d3c2ad2e
comparison
equal deleted inserted replaced
48051:98c0408324e6 48052:d07d38ef6362
573 assert not possibly_dirty 573 assert not possibly_dirty
574 item = DirstateItem.new_from_p2() 574 item = DirstateItem.new_from_p2()
575 elif possibly_dirty: 575 elif possibly_dirty:
576 item = DirstateItem.new_possibly_dirty() 576 item = DirstateItem.new_possibly_dirty()
577 else: 577 else:
578 assert size is not None
579 assert mtime is not None
578 size = size & rangemask 580 size = size & rangemask
579 mtime = mtime & rangemask 581 mtime = mtime & rangemask
580 item = DirstateItem.new_normal(mode, size, mtime) 582 item = DirstateItem.new_normal(mode, size, mtime)
581 self._rustmap.addfile(f, item) 583 self._rustmap.addfile(f, item)
582 if added: 584 if added: