changeset 109:a2e8057117d3

obsolete: smarter initialisation of obsolete stuff from disk.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 19 Dec 2011 12:19:00 +0100
parents 85271a8a7fb9
children 6d461c2143a0
files hgext/obsolete.py
diffstat 1 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py	Mon Dec 19 12:18:04 2011 +0100
+++ b/hgext/obsolete.py	Mon Dec 19 12:19:00 2011 +0100
@@ -116,8 +116,8 @@
         shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
                  'publishedheads()']
         basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
-        for rev in scmutil.revrange(ctx._repo, [basicquery]):
-            ctx._repo.changelog.hiddenrevs.add(rev)
+        ctx._repo.changelog.hiddenrevs.update(
+            scmutil.revrange(ctx._repo, [basicquery]))
         ctx._repo.changelog.hiddeninit = True
 
     return ohidden(ctx)
@@ -130,7 +130,7 @@
     """filter obsolet entry"""
     args = revset.getargs(x, 0, 0, 'publicheads takes no arguments')
     # XXX slow stop using context
-    return [r for r in subset if repo[r].obsolete()]
+    return [r for r in subset if r in repo._obsoleteset]
 
 ### Other Extension compat
 ############################
@@ -331,6 +331,16 @@
             """return the set of node that <node> make obsolete (sub)"""
             return self._obssubrels.get(node, set())
 
+        @util.propertycache
+        def _obsoleteset(self):
+            obs = set()
+            for obj in self._obsobjrels:
+                try:
+                    obs.add(self.changelog.rev(obj))
+                except error.LookupError:
+                    pass
+            return obs
+
         def addobsolete(self, sub, obj):
             """Add a relation marking that node <sub> is a new version of <obj>"""
             if sub == nullid:
@@ -351,6 +361,12 @@
             except (error.RepoLookupError, error.LookupError):
                 pass #unknow revision (but keep propagating the data
             self._writeobsrels()
+            if '_obsobjrels' in vars(self):
+                del self._obsobjrels
+            if '_obssubrels' in vars(self):
+                del self._obssubrels
+            if '_obsoleteset' in vars(self):
+                del self._obsoleteset
 
         ### obsolete storage
         @util.propertycache