context: remove basectx.__int__ (API)
basectx is the only type in the repo having __int__ implemented.
This magic method can result in unexpected coercion. Furthermore,
having it implemented is wrong for some contexts, since rev() may
return None in some cases.
Previous commits removed known cases in core where contexts are
coerced to integers. So let's delete basectx.__int__.
This commit is a bit dangerous. While the test suite passes, there
are likely still some callers in core that rely on __int__ that
don't have test coverage. An alternative would be to issue a
deprecation warning and let this bake for a few releases.
.. api::
context.basectx no longer implements __int__. Context instances
will no longer cast to ints. Consumers should call ``ctx.rev()``
instead.
Differential Revision: https://phab.mercurial-scm.org/D2433
--- a/mercurial/context.py Sat Feb 24 11:17:10 2018 -0800
+++ b/mercurial/context.py Sat Feb 24 11:21:14 2018 -0800
@@ -78,9 +78,6 @@
__str__ = encoding.strmethod(__bytes__)
- def __int__(self):
- return self.rev()
-
def __repr__(self):
return r"<%s %s>" % (type(self).__name__, str(self))