diff mercurial/context.py @ 31483:413b44003462

py3: add __bool__ to every class defining __nonzero__ __nonzero__ was renamed to __bool__ in Python 3. This patch simply aliases __bool__ to __nonzero__ for every class implementing __nonzero__.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 13 Mar 2017 12:40:14 -0700
parents 0e7a6279ff6e
children c93cdfa131a8
line wrap: on
line diff
--- a/mercurial/context.py	Mon Mar 13 21:58:43 2017 -0700
+++ b/mercurial/context.py	Mon Mar 13 12:40:14 2017 -0700
@@ -534,6 +534,8 @@
     def __nonzero__(self):
         return self._rev != nullrev
 
+    __bool__ = __nonzero__
+
     @propertycache
     def _changeset(self):
         return self._repo.changelog.changelogrevision(self.rev())
@@ -722,6 +724,8 @@
             # file is missing
             return False
 
+    __bool__ = __nonzero__
+
     def __str__(self):
         try:
             return "%s@%s" % (self.path(), self._changectx)
@@ -1238,6 +1242,8 @@
     def __nonzero__(self):
         return True
 
+    __bool__ = __nonzero__
+
     def _buildflagfunc(self):
         # Create a fallback function for getting file flags when the
         # filesystem doesn't support them
@@ -1711,6 +1717,8 @@
     def __nonzero__(self):
         return True
 
+    __bool__ = __nonzero__
+
     def linkrev(self):
         # linked to self._changectx no matter if file is modified or not
         return self.rev()