compat: make obscache code compatible with Mercurial version prior to 4.2 stable
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 03 May 2017 12:54:11 +0200
branchstable
changeset 2315 e16f6bef5848
parent 2314 2e0a15985657
child 2316 35a548465647
compat: make obscache code compatible with Mercurial version prior to 4.2 the phasecache.getrevset method is new in 4.2.
hgext3rd/evolve/obscache.py
--- a/hgext3rd/evolve/obscache.py	Wed May 03 12:41:54 2017 +0200
+++ b/hgext3rd/evolve/obscache.py	Wed May 03 12:54:11 2017 +0200
@@ -17,6 +17,7 @@
     obsolete,
     phases,
     node,
+    util,
 )
 
 from . import (
@@ -329,7 +330,11 @@
     """the set of obsolete revisions"""
     obs = set()
     repo = repo.unfiltered()
-    notpublic = repo._phasecache.getrevset(repo, (phases.draft, phases.secret))
+    if util.safehasattr(repo._phasecache, 'getrevset'):
+        notpublic = repo._phasecache.getrevset(repo, (phases.draft, phases.secret))
+    else:
+        # < hg-4.2 compat
+        notpublic = repo.revs("not public()")
     if notpublic:
         obscache = repo.obsstore.obscache
         # Since we warm the cache at the end of every transaction, the cache