Patchwork [1,of,2,V3] manifest: make uses of _mancache aware of contexts

login
register
mail settings
Submitter Durham Goode
Date Sept. 12, 2016, 6:01 p.m.
Message ID <0570e4b415b5814633cf.1473703312@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/16597/
State Superseded
Headers show

Comments

Durham Goode - Sept. 12, 2016, 6:01 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1473702943 25200
#      Mon Sep 12 10:55:43 2016 -0700
# Node ID 0570e4b415b5814633cfe1f66b88f487c08cfa17
# Parent  8a658b8b795aaea5e9fe34ae26a49b4656c594cb
manifest: make uses of _mancache aware of contexts

In a future patch we will change manifestctx and treemanifestctx to no longer
derive from manifestdict and treemanifest, respectively. This means that
consumers of the _mancache will now need to be aware of the different between
the two, until we get rid of the manifest entirely and the _mancache becomes
only filled with ctxs.
via Mercurial-devel - Sept. 12, 2016, 6:28 p.m.
On Mon, Sep 12, 2016 at 11:01 AM, Durham Goode <durham@fb.com> wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1473702943 25200
> #      Mon Sep 12 10:55:43 2016 -0700
> # Node ID 0570e4b415b5814633cfe1f66b88f487c08cfa17
> # Parent  8a658b8b795aaea5e9fe34ae26a49b4656c594cb
> manifest: make uses of _mancache aware of contexts
>
> In a future patch we will change manifestctx and treemanifestctx to no longer
> derive from manifestdict and treemanifest, respectively. This means that
> consumers of the _mancache will now need to be aware of the different between
> the two, until we get rid of the manifest entirely and the _mancache becomes
> only filled with ctxs.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -204,8 +204,8 @@ class bundlemanifest(bundlerevlog, manif
>          if isinstance(node, int):
>              node = self.node(node)
>
> -        if node in self._mancache:
> -            result = self._mancache[node].text()
> +        if node in self.fulltextcache:
> +            result = self.fulltextcache[node].tostring()
>          else:
>              result = manifest.manifest.revision(self, nodeorrev)
>          return result
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -1130,7 +1130,11 @@ class manifest(manifestrevlog):
>          if node == revlog.nullid:
>              return self._newmanifest() # don't upset local cache
>          if node in self._mancache:
> -            return self._mancache[node]
> +            cached = self._mancache[node]
> +            if (isinstance(cached, manifestctx) or
> +                isinstance(cached, treemanifestctx)):
> +                cached = cached

Unless I'm missing something, this part looks pretty silly now... What to do?

> +            return cached
>          if self._treeondisk:
>              def gettext():
>                  return self.revision(node)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Durham Goode - Sept. 12, 2016, 6:41 p.m.
On 9/12/16 11:28 AM, Martin von Zweigbergk wrote:
> On Mon, Sep 12, 2016 at 11:01 AM, Durham Goode <durham@fb.com> wrote:
>> # HG changeset patch
>> # User Durham Goode <durham@fb.com>
>> # Date 1473702943 25200
>> #      Mon Sep 12 10:55:43 2016 -0700
>> # Node ID 0570e4b415b5814633cfe1f66b88f487c08cfa17
>> # Parent  8a658b8b795aaea5e9fe34ae26a49b4656c594cb
>> manifest: make uses of _mancache aware of contexts
>>
>> In a future patch we will change manifestctx and treemanifestctx to no longer
>> derive from manifestdict and treemanifest, respectively. This means that
>> consumers of the _mancache will now need to be aware of the different between
>> the two, until we get rid of the manifest entirely and the _mancache becomes
>> only filled with ctxs.
>>
>> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
>> --- a/mercurial/bundlerepo.py
>> +++ b/mercurial/bundlerepo.py
>> @@ -204,8 +204,8 @@ class bundlemanifest(bundlerevlog, manif
>>           if isinstance(node, int):
>>               node = self.node(node)
>>
>> -        if node in self._mancache:
>> -            result = self._mancache[node].text()
>> +        if node in self.fulltextcache:
>> +            result = self.fulltextcache[node].tostring()
>>           else:
>>               result = manifest.manifest.revision(self, nodeorrev)
>>           return result
>> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
>> --- a/mercurial/manifest.py
>> +++ b/mercurial/manifest.py
>> @@ -1130,7 +1130,11 @@ class manifest(manifestrevlog):
>>           if node == revlog.nullid:
>>               return self._newmanifest() # don't upset local cache
>>           if node in self._mancache:
>> -            return self._mancache[node]
>> +            cached = self._mancache[node]
>> +            if (isinstance(cached, manifestctx) or
>> +                isinstance(cached, treemanifestctx)):
>> +                cached = cached
> Unless I'm missing something, this part looks pretty silly now... What to do?
Hmm, you're right.  Guess I can move this chunk to the next patch.
>
>> +            return cached
>>           if self._treeondisk:
>>               def gettext():
>>                   return self.revision(node)
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DQIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=ZLtTv_j8uDMAXOnZB_H8i5W7p97Ca2xOWYfCD0PRS1E&s=2q1nWZy9gSbKjd63Eac2aGA8FfEVl8G-c9nMti5fG_M&e=

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -204,8 +204,8 @@  class bundlemanifest(bundlerevlog, manif
         if isinstance(node, int):
             node = self.node(node)
 
-        if node in self._mancache:
-            result = self._mancache[node].text()
+        if node in self.fulltextcache:
+            result = self.fulltextcache[node].tostring()
         else:
             result = manifest.manifest.revision(self, nodeorrev)
         return result
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1130,7 +1130,11 @@  class manifest(manifestrevlog):
         if node == revlog.nullid:
             return self._newmanifest() # don't upset local cache
         if node in self._mancache:
-            return self._mancache[node]
+            cached = self._mancache[node]
+            if (isinstance(cached, manifestctx) or
+                isinstance(cached, treemanifestctx)):
+                cached = cached
+            return cached
         if self._treeondisk:
             def gettext():
                 return self.revision(node)