obsolete: smarter initialisation of obsolete stuff from disk.
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 19 Dec 2011 12:19:00 +0100
changeset 109 a2e8057117d3
parent 108 85271a8a7fb9
child 110 6d461c2143a0
obsolete: smarter initialisation of obsolete stuff from disk.
hgext/obsolete.py
--- 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