diff hgext/obsolete.py @ 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 5dcece86aeb0
children eae9be0ee00e
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