cleanup: replace False identity testing with an explicit token object
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 05 May 2016 19:32:51 +0200
changeset 29150 0e9ed09f5fe9
parent 29149 2e40fada340b
child 29151 7996c3acc33b
cleanup: replace False identity testing with an explicit token object The recommended way to check default value (when None is not as option) is a token object. Identity testing to integer is less explicit and not guaranteed to work in all implementations.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed May 11 09:31:47 2016 +0200
+++ b/mercurial/dirstate.py	Thu May 05 19:32:51 2016 +0200
@@ -74,6 +74,8 @@
                 raise
     return (vfs(filename), False)
 
+_token = object()
+
 class dirstate(object):
 
     def __init__(self, opener, ui, root, validate):
@@ -688,12 +690,12 @@
         self._pl = (parent, nullid)
         self._dirty = True
 
-    def write(self, tr=False):
+    def write(self, tr=_token):
         if not self._dirty:
             return
 
         filename = self._filename
-        if tr is False: # not explicitly specified
+        if tr is _token: # not explicitly specified
             self._ui.deprecwarn('use dirstate.write with '
                                'repo.currenttransaction()',
                                '3.9')