D2423: templatekw: use ctx.rev() instead of casting context to int

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Feb 24 19:31:02 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  basectx has __int__ implemented. Per mailing list discussion
  with Yuya, we don't like having this implemented because it is
  too much magic and in some cases rev() will return None, which
  isn't an int.
  
  So convert a `'%d' % ctx` to ctx.rev() instead.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2423

AFFECTED FILES
  mercurial/templatekw.py

CHANGE DETAILS

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -400,7 +400,7 @@
     """List of strings. The children of the changeset."""
     args = pycompat.byteskwargs(args)
     ctx = args['ctx']
-    childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
+    childrevs = ['%d:%s' % (cctx.rev(), cctx) for cctx in ctx.children()]
     return showlist('children', childrevs, args, element='child')
 
 # Deprecated, but kept alive for help generation a purpose.



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list