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

login
register
mail settings
Submitter Boris Feld
Date July 16, 2018, 4:30 p.m.
Message ID <94a6a0ef74f6e52cbb26.1531758616@FB-lair>
Download mbox | patch
Permalink /patch/32864/
State Accepted
Headers show

Comments

Boris Feld - July 16, 2018, 4:30 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.

Patch

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)