Patchwork [1,of,4] revlog: do inclusive descendant testing (API)

login
register
mail settings
Submitter Paul Morelle
Date July 1, 2018, 6:38 a.m.
Message ID <c6a8430582d584770c87.1530427119@belenos.localdomain>
Download mbox | patch
Permalink /patch/32537/
State Accepted
Headers show

Comments

Paul Morelle - July 1, 2018, 6:38 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1529621623 -3600
#      Thu Jun 21 23:53:43 2018 +0100
# Node ID c6a8430582d584770c873a3b6234750482b9b65e
# Parent  a0e185f104541858a0b049e1fb67c4d113930a9a
# EXP-Topic descendant
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c6a8430582d5
revlog: do inclusive descendant testing (API)

In many other places, a revision is considered a descendant of itself.  We
update the behavior of `revlog.descendant()` to match this. (for example.
`revlog.isancestor` does inclusive testing).

No tests break, so it seems safe to do so.

This will make it easier to use a more efficient implementation in a later
changeset.

Patch

diff -r a0e185f10454 -r c6a8430582d5 mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Feb 02 14:21:04 2018 -0800
+++ b/mercurial/revlog.py	Thu Jun 21 23:53:43 2018 +0100
@@ -1378,6 +1378,8 @@ 
     def descendant(self, start, end):
         if start == nullrev:
             return True
+        elif start == end:
+            return True
         for i in self.descendants([start]):
             if i == end:
                 return True