Patchwork [4,of,8,V6] context: take advantage of `_descendantrev` in introrev if available

login
register
mail settings
Submitter Boris Feld
Date Nov. 19, 2018, 4:49 p.m.
Message ID <16ef27511c0b9337d1b6.1542646183@localhost.localdomain>
Download mbox | patch
Permalink /patch/36651/
State Accepted
Headers show

Comments

Boris Feld - Nov. 19, 2018, 4:49 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539125434 -7200
#      Wed Oct 10 00:50:34 2018 +0200
# Node ID 16ef27511c0b9337d1b6cba011bda8b46608dcc6
# Parent  7c37df72e30462089a76be6f3b752f4e374d949b
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 16ef27511c0b
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
@@ -782,6 +782,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()