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

login
register
mail settings
Submitter Boris Feld
Date Oct. 4, 2018, 2:44 p.m.
Message ID <36a3f6fc8dbd727e1369.1538664279@localhost.localdomain>
Download mbox | patch
Permalink /patch/35453/
State Accepted
Headers show

Comments

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

Patch

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()