obsolete: move version checks at the start of the file
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 07 Aug 2012 14:32:54 +0200
changeset 433 aa1255c2ac8f
parent 432 6347bc69b49a
child 434 9863e196cc65
obsolete: move version checks at the start of the file
hgext/obsolete.py
--- a/hgext/obsolete.py	Tue Aug 07 14:19:18 2012 +0200
+++ b/hgext/obsolete.py	Tue Aug 07 14:32:54 2012 +0200
@@ -56,6 +56,13 @@
 _unpack = struct.unpack
 
 from mercurial import util
+
+try:
+    from mercurial import obsolete
+    obsolete._enabled = True
+except ImportError:
+        raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)')
+
 from mercurial import context
 from mercurial import revset
 from mercurial import scmutil
@@ -71,9 +78,7 @@
 from mercurial import localrepo
 from mercurial import cmdutil
 from mercurial import templatekw
-from mercurial import obsolete
 from mercurial.localrepo import storecache
-obsolete._enabled = True
 
 # This extension hold the following code
 #
@@ -783,8 +788,6 @@
     if not repo.local():
         return
 
-    if not util.safehasattr(repo.opener, 'tryread'):
-        raise util.Abort('Obsolete extension requires Mercurial 2.2 (or later)')
     opush = repo.push
     o_updatebranchcache = repo.updatebranchcache