[PATCH 1 of 2] context: reintroduce `ctx.descendant` as deprecated

Boris Feld boris.feld at octobus.net
Mon Jul 16 16:30:16 UTC 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1531750872 -7200
#      Mon Jul 16 16:21:12 2018 +0200
# Node ID 94a6a0ef74f6e52cbb26e3461df2f155ab873039
# Parent  3c569172848d329a81b1420d7cd8a5549b48f25f
# EXP-Topic deprecate-descendant
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 94a6a0ef74f6
context: reintroduce `ctx.descendant` as deprecated

Reintroduce `ctx.descendant` to help extensions authors update their
extensions in order to use the new API.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -589,6 +589,12 @@ class changectx(basectx):
                             short(n) for n in sorted(cahs) if n != anc))
         return changectx(self._repo, anc)
 
+    def descendant(self, other):
+        msg = (b'ctx.descendant(other) is deprecated, '
+               'use ctx.isancestorof(other)')
+        self._repo.ui.deprecwarn(msg, b'4.7')
+        return self.isancestorof(other)
+
     def isancestorof(self, other):
         """True if this changeset is an ancestor of other"""
         return self._repo.changelog.isancestorrev(self._rev, other._rev)


More information about the Mercurial-devel mailing list