Move findcmd switch to imports kwmap-templates
authorChristian Ebert <blacktrash@gmx.net>
Fri, 15 Jun 2007 08:56:26 +0200
branchkwmap-templates
changeset 163 c18c0c80b6c2
parent 162 017dbf710056
child 164 d16332759801
Move findcmd switch to imports
hgkw/keyword.py
--- a/hgkw/keyword.py	Tue Jun 12 18:45:26 2007 +0200
+++ b/hgkw/keyword.py	Fri Jun 15 08:56:26 2007 +0200
@@ -88,6 +88,12 @@
 from mercurial.i18n import gettext as _
 from mercurial import commands, fancyopts, templater, util
 from mercurial import cmdutil, context, filelog
+# findcmd might be in cmdutil or commands
+# depending on mercurial version
+if hasattr(cmdutil, "findcmd"):
+    findcmd = cmdutil.findcmd
+else:
+    findcmd = commands.findcmd
 import os, re, sys, time
 
 deftemplates = {
@@ -113,10 +119,7 @@
         raise commands.ParseError(None, inst)
     if args:
         cmd = args[0]
-        if hasattr(cmdutil, "findcmd"):
-            aliases, i = cmdutil.findcmd(ui, cmd)
-        else:
-            aliases, i = commands.findcmd(ui, cmd)
+        aliases, i = findcmd(ui, cmd)
         return aliases[0]
 
 class kwtemplater(object):