This is an archive of the discontinued Mercurial Phabricator instance.

context: remove basectx.__int__ (API)
ClosedPublic

Authored by indygreg on Feb 24 2018, 2:30 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Feb 24 2018, 2:30 PM
yuja accepted this revision.Feb 24 2018, 8:36 PM
This revision is now accepted and ready to land.Feb 24 2018, 8:36 PM
yuja added a comment.Feb 24 2018, 8:39 PM

"While the test suite passes, there are likely still some callers in core
that rely on int that don't have test coverage."

I think we can fix them in next 2 months. Queued with delight, thanks.

This revision was automatically updated to reflect the committed changes.