nicer hiddenrevs init
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 19 Dec 2011 16:27:00 +0100
changeset 114 1a64195e2b09
parent 113 3bdabdbb4140
child 115 d60eddda9546
nicer hiddenrevs init
hgext/obsolete.py
--- a/hgext/obsolete.py	Mon Dec 19 14:37:24 2011 +0100
+++ b/hgext/obsolete.py	Mon Dec 19 16:27:00 2011 +0100
@@ -91,6 +91,7 @@
 from mercurial import discovery
 from mercurial import error
 from mercurial import commands
+from mercurial import changelog
 from mercurial.node import hex, bin, short, nullid
 from mercurial.lock import release
 
@@ -105,23 +106,6 @@
 
 context.changectx.obsolete = obsolete
 
-ohidden = context.changectx.hidden
-def hidden(ctx):
-    """hacked version fo hidden that also initialize hiddenrevs set
-
-    XXX we need something cleaner"""
-    # hack to fill hiddenrevs
-    # compute hidden (XXX should move elsewhere)
-    if not getattr(ctx._repo.changelog, 'hiddeninit', False):
-        shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
-                 'public()']
-        basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
-        ctx._repo.changelog.hiddenrevs.update(
-            scmutil.revrange(ctx._repo, [basicquery]))
-        ctx._repo.changelog.hiddeninit = True
-
-    return ohidden(ctx)
-context.changectx.hidden = hidden
 
 ### revset
 #############################
@@ -486,5 +470,29 @@
             finally:
                 release(lock, wlock)
 
+        @scmutil.filecache('00changelog.i', True)
+        def changelog(self):
+            changelog = getattr(super(obsoletingrepo, self), 'changelog')
+            assert not changelog.__dict__.pop('hiddenrevs', ())
+            def _sethidden(changelog, value):
+                print 'COIN COIN', value
+                assert not value
+
+
+            class hchangelog(changelog.__class__):
+                @util.propertycache
+                def hiddenrevs(changelog):
+                    shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
+                             'public()']
+                    basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
+                    # !!! self is repo not changelog
+                    result = set(scmutil.revrange(self, [basicquery]))
+                    return result
+            changelog.__class__ = hchangelog
+            return changelog
+
+
+
+
     repo.__class__ = obsoletingrepo