[obsolete] fix new api: use the new phase cache api
authorAlain Leufroy <alain.leufroy@logilab.fr>
Tue, 29 May 2012 10:27:33 +0200
changeset 252 470232cea503
parent 251 a60d11973ff3
child 253 8ee6c5b98d73
[obsolete] fix new api: use the new phase cache api Introduced by `b6081c2c4647@mercurial <http://selenic.com/repo/hg/rev/b6081c2c4647>`_
hgext/obsolete.py
--- a/hgext/obsolete.py	Wed May 30 14:17:33 2012 +0200
+++ b/hgext/obsolete.py	Tue May 29 10:27:33 2012 +0200
@@ -96,6 +96,7 @@
 from mercurial import phases
 from mercurial.node import hex, bin, short, nullid
 from mercurial.lock import release
+from mercurial import localrepo
 
 try:
     from mercurial.localrepo import storecache
@@ -140,7 +141,14 @@
 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]
+    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"""