Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 46653:9306a16ca964
debugcommands: prevent using `is False`
I was touching this code in a future patch and marmoute warned about usage of
`is False` here.
Quoting marmoute:
```
"is False" is going to check if the object you have the very same object in
memory than the one Python allocated for False (in practice 0)
This will "mostly work" on cpython because of implementation details, but
is semantically wrong and can start breaking unexpectedly
```
Differential Revision: https://phab.mercurial-scm.org/D10014
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 16 Feb 2021 20:38:14 +0530 |
parents | 5aac1a1a5beb |
children | e4e971abb6a3 |
comparison
equal
deleted
inserted
replaced
46652:75832107ec07 | 46653:9306a16ca964 |
---|---|
3868 for r in repo: | 3868 for r in repo: |
3869 node = repo[r].node() | 3869 node = repo[r].node() |
3870 tagsnode = cache.getfnode(node, computemissing=False) | 3870 tagsnode = cache.getfnode(node, computemissing=False) |
3871 if tagsnode: | 3871 if tagsnode: |
3872 tagsnodedisplay = hex(tagsnode) | 3872 tagsnodedisplay = hex(tagsnode) |
3873 elif tagsnode is False: | 3873 elif tagsnode is None: |
3874 tagsnodedisplay = b'missing' | |
3875 else: | |
3874 tagsnodedisplay = b'invalid' | 3876 tagsnodedisplay = b'invalid' |
3875 else: | |
3876 tagsnodedisplay = b'missing' | |
3877 | 3877 |
3878 ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay)) | 3878 ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay)) |
3879 | 3879 |
3880 | 3880 |
3881 @command( | 3881 @command( |