Patchwork [2,of,5,V5] context: take advantage of `_descendantrev` in introrev if available

login
register
mail settings
Submitter Boris Feld
Date Oct. 10, 2018, 8:41 a.m.
Message ID <927d87bd28e0e7791b49.1539160906@localhost.localdomain>
Download mbox | patch
Permalink /patch/35596/
State New
Headers show

Comments

Boris Feld - Oct. 10, 2018, 8:41 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539125434 -7200
#      Wed Oct 10 00:50:34 2018 +0200
# Node ID 927d87bd28e0e7791b494a70701cb81a3ffad73d
# Parent  37ee24df8c3b342bde56b950aa09ac0d123e0145
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 927d87bd28e0
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()