Commits

Pierre-Yves David committed b9a5a59

proper computation of hidden changeset.

Comments (0)

Files changed (2)

 from mercurial import util
 from mercurial import context
 from mercurial import revset
+from mercurial import scmutil
 from mercurial.node import hex, bin
 
 # Patch changectx
 
 ohidden = context.changectx.hidden
 def hidden(ctx):
-    ctx._repo._obsobjrels # XXX hack to fill hiddenrevs
+    # hack to fill hiddenrevs
+    # compute hidden (XXX should move elsewhere)
+    if not getattr(ctx._repo.changelog, 'hiddeninit', False):
+        basicquery = 'obsolete() - (ancestors(not obsolete()))'
+        for rev in scmutil.revrange(ctx._repo, [basicquery]):
+            ctx._repo.changelog.hiddenrevs.add(rev)
+        ctx._repo.changelog.hiddeninit = True
+
     return ohidden(ctx)
 context.changectx.hidden = hidden
 
                 for obj in objs:
                     objrels.setdefault(obj, set()).add(sub)
 
-            # compute hidden (XXX should move elsewhere)
-            for obj in objrels:
-                self.changelog.hiddenrevs.add(repo[obj].rev())
-
             #
             return objrels
 

tests/test-obsolete.t

   summary:     add c
   
 
+test obsolete changeset with no-obsolete descendant
+  $ hg up 1 -q
+  $ mkcommit "obsol_c'" # 4 (on 1)
+  created new head
+  $ hg debugobsolete 4 3
+  $ hg log
+  changeset:   4:725c380fe99b
+  tag:         tip
+  parent:      1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add obsol_c'
+  
+  changeset:   1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add b
+  
+  changeset:   0:1f0dee641bb7
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add a
+  
+  $ hg log -r 'obsolete()' --hidden
+  changeset:   2:4538525df7e2
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add c
+  
+  changeset:   3:0d3f46688ccc
+  parent:      1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add obsol_c
+  
+  $ hg up 3 -q
+  $ mkcommit d # 5 (on 3)
+  $ hg log -r 'obsolete()'
+  changeset:   3:0d3f46688ccc
+  parent:      1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add obsol_c
+  
+