changeset 433:aa1255c2ac8f

obsolete: move version checks at the start of the file
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 07 Aug 2012 14:32:54 +0200
parents 6347bc69b49a
children 9863e196cc65
files hgext/obsolete.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py
+++ b/hgext/obsolete.py
@@ -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