D10014: debugcommands: prevent using `is False`
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Feb 17 19:44:34 UTC 2021
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10014
AFFECTED FILES
mercurial/debugcommands.py
CHANGE DETAILS
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -3870,10 +3870,10 @@
tagsnode = cache.getfnode(node, computemissing=False)
if tagsnode:
tagsnodedisplay = hex(tagsnode)
- elif tagsnode is False:
+ elif tagsnode is None:
+ tagsnodedisplay = b'missing'
+ else:
tagsnodedisplay = b'invalid'
- else:
- tagsnodedisplay = b'missing'
ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay))
To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list