revset: avoid implicit None testing in revset
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 23 Sep 2015 00:41:07 -0700
changeset 26307 428a8747f4ee
parent 26306 d157e1f18e3f
child 26308 f2788794183a
revset: avoid implicit None testing in revset Implicit None testing is a very good way to get in trouble. We explicitly test for None.
mercurial/revset.py
--- a/mercurial/revset.py	Sun Sep 20 16:53:42 2015 -0700
+++ b/mercurial/revset.py	Wed Sep 23 00:41:07 2015 -0700
@@ -3225,10 +3225,13 @@
         return lambda: self._iterfilter(it())
 
     def __nonzero__(self):
-        it = self
-        fast = self.fastasc or self.fastdesc
-        if fast:
+        fast = self.fastasc
+        if fast is None:
+            fast = self.fastdesc
+        if fast is not None:
             it = fast()
+        else:
+            it = self
 
         for r in it:
             return True