backout 97b75bbfacc5. Use cached version of obsolete, unstable and extinct
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 26 Jul 2012 15:17:34 +0200
changeset 393 ac8213faeda8
parent 392 04e67d6f1913
child 397 0bd63f294a6f
backout 97b75bbfacc5. Use cached version of obsolete, unstable and extinct The core version are far too slow
hgext/obsolete.py
--- a/hgext/obsolete.py	Thu Jul 26 15:09:08 2012 +0200
+++ b/hgext/obsolete.py	Thu Jul 26 15:17:34 2012 +0200
@@ -87,6 +87,22 @@
 ### Patch changectx
 #############################
 
+def unstable(ctx):
+    """is the changeset unstable (have obsolete ancestor)"""
+    if ctx.node() is None:
+        return False
+    return ctx.rev() in ctx._repo._unstableset
+
+context.changectx.unstable = unstable
+
+def extinct(ctx):
+    """is the changeset extinct by other"""
+    if ctx.node() is None:
+        return False
+    return ctx.rev() in ctx._repo._extinctset
+
+context.changectx.extinct = extinct
+
 def latecomer(ctx):
     """is the changeset latecomer (Try to succeed to public change)"""
     if ctx.node() is None:
@@ -112,11 +128,33 @@
     args = revset.getargs(x, 0, 0, 'hidden takes no argument')
     return [r for r in subset if r in repo.changelog.hiddenrevs]
 
+def revsetobsolete(repo, subset, x):
+    """obsolete changesets"""
+    args = revset.getargs(x, 0, 0, 'obsolete takes no argument')
+    return [r for r in subset if r in repo._obsoleteset and repo._phasecache.phase(repo, r) > 0]
+
+# XXX Backward compatibility, to be removed once stabilized
+if '_phasecache' not in vars(localrepo.localrepository): # new api
+    def revsetobsolete(repo, subset, x):
+        """obsolete changesets"""
+        args = revset.getargs(x, 0, 0, 'obsolete takes no argument')
+        return [r for r in subset if r in repo._obsoleteset and repo._phaserev[r] > 0]
+
+def revsetunstable(repo, subset, x):
+    """non obsolete changesets descendant of obsolete one"""
+    args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
+    return [r for r in subset if r in repo._unstableset]
+
 def revsetsuspended(repo, subset, x):
     """obsolete changesets with non obsolete descendants"""
     args = revset.getargs(x, 0, 0, 'suspended takes no arguments')
     return [r for r in subset if r in repo._suspendedset]
 
+def revsetextinct(repo, subset, x):
+    """obsolete changesets without obsolete descendants"""
+    args = revset.getargs(x, 0, 0, 'extinct takes no arguments')
+    return [r for r in subset if r in repo._extinctset]
+
 def revsetlatecomer(repo, subset, x):
     """latecomer, Try to succeed to public change"""
     args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
@@ -320,7 +358,10 @@
 def extsetup(ui):
 
     revset.symbols["hidden"] = revsethidden
+    revset.symbols["obsolete"] = revsetobsolete
+    revset.symbols["unstable"] = revsetunstable
     revset.symbols["suspended"] = revsetsuspended
+    revset.symbols["extinct"] = revsetextinct
     revset.symbols["latecomer"] = revsetlatecomer
     revset.symbols["conflicting"] = revsetconflicting
     revset.symbols["obsparents"] = revsetprecursors  # DEPR
@@ -334,11 +375,11 @@
 
     # warning about more obsolete
     for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']:
-        extensions.wrapcommand(commands.table, cmd, warnobserrors)
+        entry = extensions.wrapcommand(commands.table, cmd, warnobserrors)
     try:
         rebase = extensions.find('rebase')
         if rebase:
-            extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)
+            entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)
             extensions.wrapfunction(rebase, 'buildstate', buildstate)
             extensions.wrapfunction(rebase, 'defineparents', defineparents)
             extensions.wrapfunction(rebase, 'concludenode', concludenode)