Patchwork [1,of,2,topic-ext] init: cache repo.topics

login
register
mail settings
Submitter timeless
Date Aug. 26, 2016, 4:59 p.m.
Message ID <81def069bd64c516610e.1472230778@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/16455/
State Accepted
Headers show

Comments

timeless - Aug. 26, 2016, 4:59 p.m.
# HG changeset patch
# User timeless@gmail.com
# Date 1472230322 0
#      Fri Aug 26 16:52:02 2016 +0000
# Node ID 81def069bd64c516610e507279070cef5ca72d7f
# Parent  cf9414f2b5cddd65d21041527981d15a6fb6fd67
init: cache repo.topics
Pierre-Yves David - Aug. 26, 2016, 9:22 p.m.
On 08/26/2016 06:59 PM, timeless wrote:
> # HG changeset patch
> # User timeless@gmail.com
> # Date 1472230322 0
> #      Fri Aug 26 16:52:02 2016 +0000
> # Node ID 81def069bd64c516610e507279070cef5ca72d7f
> # Parent  cf9414f2b5cddd65d21041527981d15a6fb6fd67
> init: cache repo.topics

Thanks for looking into this. That turned out a less scary step that one 
might have expected :-)

> diff -r cf9414f2b5cd -r 81def069bd64 hgext3rd/topic/__init__.py
> --- a/hgext3rd/topic/__init__.py	Tue Aug 23 21:18:47 2016 +0200
> +++ b/hgext3rd/topic/__init__.py	Fri Aug 26 16:52:02 2016 +0000
> @@ -144,10 +144,13 @@
>
>          @property
>          def topics(self):
> +            if self._topics is not None:
> +                return self._topics
>              topics = set(['', self.currenttopic])
>              for c in self.set('not public()'):
>                  topics.add(c.topic())
>              topics.remove('')
> +            self._topics = topics
>              return topics
>
>          @property
> @@ -167,6 +170,7 @@
>
>          def invalidatecaches(self):
>              super(topicrepo, self).invalidatecaches()
> +            self._topics = None

I'm afraid this is a bit to weak as I'm not sure 'invalidatecaches' in 
called in all the necessary case. Using 'invalidatevolatilesets' -might- 
be a bit too much but will probably do the trick.

Eventually we should probably dig a bit more and document what to expect 
from the various cache invalidation level.
timeless - Aug. 26, 2016, 9:40 p.m.
i don't have the resources to push this further for at least a week,
if you could take it and run with it, that'd be great...

On Fri, Aug 26, 2016 at 5:22 PM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
>
>
> On 08/26/2016 06:59 PM, timeless wrote:
>>
>> # HG changeset patch
>> # User timeless@gmail.com
>> # Date 1472230322 0
>> #      Fri Aug 26 16:52:02 2016 +0000
>> # Node ID 81def069bd64c516610e507279070cef5ca72d7f
>> # Parent  cf9414f2b5cddd65d21041527981d15a6fb6fd67
>> init: cache repo.topics
>
>
> Thanks for looking into this. That turned out a less scary step that one
> might have expected :-)
>
>> diff -r cf9414f2b5cd -r 81def069bd64 hgext3rd/topic/__init__.py
>> --- a/hgext3rd/topic/__init__.py        Tue Aug 23 21:18:47 2016 +0200
>> +++ b/hgext3rd/topic/__init__.py        Fri Aug 26 16:52:02 2016 +0000
>> @@ -144,10 +144,13 @@
>>
>>          @property
>>          def topics(self):
>> +            if self._topics is not None:
>> +                return self._topics
>>              topics = set(['', self.currenttopic])
>>              for c in self.set('not public()'):
>>                  topics.add(c.topic())
>>              topics.remove('')
>> +            self._topics = topics
>>              return topics
>>
>>          @property
>> @@ -167,6 +170,7 @@
>>
>>          def invalidatecaches(self):
>>              super(topicrepo, self).invalidatecaches()
>> +            self._topics = None
>
>
> I'm afraid this is a bit to weak as I'm not sure 'invalidatecaches' in
> called in all the necessary case. Using 'invalidatevolatilesets' -might- be
> a bit too much but will probably do the trick.
>
> Eventually we should probably dig a bit more and document what to expect
> from the various cache invalidation level.
>
> --
> Pierre-Yves David
Pierre-Yves David - Aug. 26, 2016, 9:53 p.m.
On 08/26/2016 11:40 PM, timeless wrote:
> i don't have the resources to push this further for at least a week,
> if you could take it and run with it, that'd be great...

I already do. I'll poke a bit around and probably take a version using 
invalidatevolatilesets.

--
Pierre-Yves David
Pierre-Yves David - Aug. 29, 2016, 12:53 p.m.
On 08/26/2016 11:53 PM, Pierre-Yves David wrote:
>
>
> On 08/26/2016 11:40 PM, timeless wrote:
>> i don't have the resources to push this further for at least a week,
>> if you could take it and run with it, that'd be great...
>
> I already do. I'll poke a bit around and probably take a version using
> invalidatevolatilesets.

I've pushed a version using invalidatevolatilesets. I'm offline the next 
couple of day but I might take another look at the end of the week.

Patch

diff -r cf9414f2b5cd -r 81def069bd64 hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Tue Aug 23 21:18:47 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Aug 26 16:52:02 2016 +0000
@@ -144,10 +144,13 @@ 
 
         @property
         def topics(self):
+            if self._topics is not None:
+                return self._topics
             topics = set(['', self.currenttopic])
             for c in self.set('not public()'):
                 topics.add(c.topic())
             topics.remove('')
+            self._topics = topics
             return topics
 
         @property
@@ -167,6 +170,7 @@ 
 
         def invalidatecaches(self):
             super(topicrepo, self).invalidatecaches()
+            self._topics = None
             if '_topiccaches' in vars(self.unfiltered()):
                 self.unfiltered()._topiccaches.clear()
 
@@ -181,6 +185,7 @@ 
             return peer
 
     repo.__class__ = topicrepo
+    repo._topics = None
     if util.safehasattr(repo, 'names'):
         repo.names.addnamespace(namespaces.namespace(
             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,