hgkw/keyword.py
branchkwmap-templates
changeset 163 c18c0c80b6c2
parent 162 017dbf710056
child 164 d16332759801
equal deleted inserted replaced
162:017dbf710056 163:c18c0c80b6c2
    86 '''
    86 '''
    87 
    87 
    88 from mercurial.i18n import gettext as _
    88 from mercurial.i18n import gettext as _
    89 from mercurial import commands, fancyopts, templater, util
    89 from mercurial import commands, fancyopts, templater, util
    90 from mercurial import cmdutil, context, filelog
    90 from mercurial import cmdutil, context, filelog
       
    91 # findcmd might be in cmdutil or commands
       
    92 # depending on mercurial version
       
    93 if hasattr(cmdutil, "findcmd"):
       
    94     findcmd = cmdutil.findcmd
       
    95 else:
       
    96     findcmd = commands.findcmd
    91 import os, re, sys, time
    97 import os, re, sys, time
    92 
    98 
    93 deftemplates = {
    99 deftemplates = {
    94         'Revision': '{node|short}',
   100         'Revision': '{node|short}',
    95         'Author': '{author|user}',
   101         'Author': '{author|user}',
   111         args = fancyopts.fancyopts(sys.argv[1:], commands.globalopts, {})
   117         args = fancyopts.fancyopts(sys.argv[1:], commands.globalopts, {})
   112     except fancyopts.getopt.GetoptError, inst:
   118     except fancyopts.getopt.GetoptError, inst:
   113         raise commands.ParseError(None, inst)
   119         raise commands.ParseError(None, inst)
   114     if args:
   120     if args:
   115         cmd = args[0]
   121         cmd = args[0]
   116         if hasattr(cmdutil, "findcmd"):
   122         aliases, i = findcmd(ui, cmd)
   117             aliases, i = cmdutil.findcmd(ui, cmd)
       
   118         else:
       
   119             aliases, i = commands.findcmd(ui, cmd)
       
   120         return aliases[0]
   123         return aliases[0]
   121 
   124 
   122 class kwtemplater(object):
   125 class kwtemplater(object):
   123     '''
   126     '''
   124     Sets up keyword templates, corresponding keyword regex, and
   127     Sets up keyword templates, corresponding keyword regex, and