hgkw/keyword.py
changeset 228 88362a9b5afd
parent 227 8ae160f24b9f
child 229 8e5ba738e36d
--- a/hgkw/keyword.py	Thu Aug 16 14:19:33 2007 +0200
+++ b/hgkw/keyword.py	Mon Aug 20 05:08:39 2007 +0200
@@ -87,19 +87,22 @@
 
 # backwards compatibility hacks
 
-# findcmd, bail_if_changed were in commands until 0c61124ad877
 try:
-    findcmd = cmdutil.findcmd
-    bail_if_changed = cmdutil.bail_if_changed
+    # cmdutil.parse moves to dispatch._parse in 18a9fbb5cd78
+    from mercurial import dispatch
+    __parse = dispatch._parse
+except ImportError:
+    try:
+        # commands.parse moves to cmdutil.parse in 0c61124ad877
+        __parse = cmdutil.parse
+    except AttributeError:
+        __parse = commands.parse
+
+try:
+    # bail_if_changed moves from commands to cmdutil in 0c61124ad877
+    _bail_if_changed = cmdutil.bail_if_changed
 except AttributeError:
-    findcmd = commands.findcmd
-    bail_if_changed = commands.bail_if_changed
-
-# cmdutil.parse moves to dispatch._parse in 18a9fbb5cd78
-try:
-    from mercurial import dispatch
-except ImportError:
-    pass
+    _bail_if_changed = commands.bail_if_changed
 
 # commands.parse/cmdutil.parse returned nothing for
 # "hg diff --rev" before 88803a69b24a due to bug in fancyopts
@@ -312,7 +315,7 @@
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        bail_if_changed(repo)
+        _bail_if_changed(repo)
         ctx = repo.changectx()
         if not ctx:
             raise hg.RepoError(_('no revision checked out'))
@@ -439,16 +442,7 @@
                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
                     'remove', 'rename', 'rollback']
 
-    def _getcmd():
-        try:
-            return dispatch._parse(ui, sys.argv[1:])[0]
-        except (ImportError, NameError):
-            try:
-                return cmdutil.parse(ui, sys.argv[1:])[0]
-            except AttributeError:
-                return commands.parse(ui, sys.argv[1:])[0]
-
-    if not repo.local() or _getcmd() in nokwcommands:
+    if not repo.local() or __parse(ui, sys.argv[1:])[0] in nokwcommands:
         return
 
     kwfmatcher = _keywordmatcher(ui, repo)