[PATCH 05 of 10 V4] context: take advantage of `_descendantrev` in introrev if available

Boris Feld boris.feld at octobus.net
Thu Oct 4 10:44:39 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1538636595 -7200
#      Thu Oct 04 09:03:15 2018 +0200
# Node ID 36a3f6fc8dbd727e1369fb29c5bda044a9b44754
# Parent  1f9af0d6ead8404e8b9c242691e68a8af703ef0e
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 36a3f6fc8dbd
context: take advantage of `_descendantrev` in introrev if available

Before this changeset, `_descendantrev` was ignored and `introrev` could
return a "wrong" result. I was previously fine because there seems to be no
existing code using both `introrev` and `_descendantrev` at the same time.
However, we would like to change that.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -787,6 +787,11 @@ class basefilectx(object):
 
         if toprev is not None:
             return self._adjustlinkrev(toprev, inclusive=True)
+        elif r'_descendantrev' in attrs:
+            introrev = self._adjustlinkrev(self._descendantrev)
+            # be nice and cache the result of the computation
+            self._changeid = introrev
+            return introrev
         else:
             return self.linkrev()
 


More information about the Mercurial-devel mailing list