Patchwork [4,of,9] unionrepo: use a lower level overide in unionrepo too

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 30, 2019, 4:39 p.m.
Message ID <b3b9c5961371426a896a.1567183173@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41434/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 30, 2019, 4:39 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1567179938 -7200
#      Fri Aug 30 17:45:38 2019 +0200
# Node ID b3b9c5961371426a896a47095a5ff8941174520a
# Parent  680d5166e27cd9029c7e1c6f983fb98e677ea10f
# EXP-Topic sidedata-prep
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b3b9c5961371
unionrepo: use a lower level overide in unionrepo too

The unionrepo class also have a strange `baserevision` hack, let's try to get
ride of it too.
Yuya Nishihara - Aug. 31, 2019, 2:45 a.m.
On Fri, 30 Aug 2019 18:39:33 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1567179938 -7200
> #      Fri Aug 30 17:45:38 2019 +0200
> # Node ID b3b9c5961371426a896a47095a5ff8941174520a
> # Parent  680d5166e27cd9029c7e1c6f983fb98e677ea10f
> # EXP-Topic sidedata-prep
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b3b9c5961371
> unionrepo: use a lower level overide in unionrepo too

> @@ -105,16 +101,13 @@ class unionrevlog(revlog.revlog):
>              node = nodeorrev
>              rev = self.rev(node)
>  
> -        if node == nullid:
> -            return ""
> -
>          if rev > self.repotiprev:
> -            text = self.revlog2.revision(node)
> -            self._revisioncache = (node, rev, text)
> +            # work around manifestrevlog NOT being a revlog
> +            revlog2 = getattr(self.revlog2, '_revlog', self.revlog2)
> +            func = revlog2._revisiondata

So we no longer set self._revisioncache, which I think is correct, but just
note that in case it wasn't.
Pierre-Yves David - Aug. 31, 2019, 9:41 a.m.
On 8/31/19 4:45 AM, Yuya Nishihara wrote:
> On Fri, 30 Aug 2019 18:39:33 +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1567179938 -7200
>> #      Fri Aug 30 17:45:38 2019 +0200
>> # Node ID b3b9c5961371426a896a47095a5ff8941174520a
>> # Parent  680d5166e27cd9029c7e1c6f983fb98e677ea10f
>> # EXP-Topic sidedata-prep
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b3b9c5961371
>> unionrepo: use a lower level overide in unionrepo too
> 
>> @@ -105,16 +101,13 @@ class unionrevlog(revlog.revlog):
>>               node = nodeorrev
>>               rev = self.rev(node)
>>   
>> -        if node == nullid:
>> -            return ""
>> -
>>           if rev > self.repotiprev:
>> -            text = self.revlog2.revision(node)
>> -            self._revisioncache = (node, rev, text)
>> +            # work around manifestrevlog NOT being a revlog
>> +            revlog2 = getattr(self.revlog2, '_revlog', self.revlog2)
>> +            func = revlog2._revisiondata
> 
> So we no longer set self._revisioncache, which I think is correct, but just
> note that in case it wasn't.

We no longer need to because and higher level layer will take care of 
that for us.

Patch

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -14,7 +14,6 @@  allowing operations like diff and log wi
 from __future__ import absolute_import
 
 from .i18n import _
-from .node import nullid
 
 from . import (
     changelog,
@@ -94,10 +93,7 @@  class unionrevlog(revlog.revlog):
 
         return mdiff.textdiff(self.revision(rev1), self.revision(rev2))
 
-    def revision(self, nodeorrev, _df=None, raw=False):
-        """return an uncompressed revision of a given node or revision
-        number.
-        """
+    def _revisiondata(self, nodeorrev, _df=None, raw=False):
         if isinstance(nodeorrev, int):
             rev = nodeorrev
             node = self.node(rev)
@@ -105,16 +101,13 @@  class unionrevlog(revlog.revlog):
             node = nodeorrev
             rev = self.rev(node)
 
-        if node == nullid:
-            return ""
-
         if rev > self.repotiprev:
-            text = self.revlog2.revision(node)
-            self._revisioncache = (node, rev, text)
+            # work around manifestrevlog NOT being a revlog
+            revlog2 = getattr(self.revlog2, '_revlog', self.revlog2)
+            func = revlog2._revisiondata
         else:
-            text = self.baserevision(rev)
-            # already cached
-        return text
+            func = super(unionrevlog, self)._revisiondata
+        return func(node, _df=_df, raw=raw)
 
     def rawdata(self, nodeorrev, _df=None):
         return self.revision(nodeorrev, _df=_df, raw=True)