diff -r b8c86166bf86 -r acd3fba02a50 hgkw/keyword.py --- a/hgkw/keyword.py Wed Nov 07 13:33:19 2007 +0100 +++ b/hgkw/keyword.py Thu Nov 08 12:59:43 2007 +0100 @@ -80,24 +80,13 @@ Or, better, use bundle/unbundle to share changes. ''' -from mercurial import commands, cmdutil, context, fancyopts +from mercurial import commands, cmdutil, context from mercurial import filelog, localrepo, revlog, templater, util from mercurial.i18n import gettext as _ import getopt, os.path, re, shutil, sys, tempfile, time # backwards compatibility hacks -try: - # cmdutil.parse moves to dispatch._parse in 18a9fbb5cd78 - # also avoid name conflict with other dispatch package(s) - from mercurial.dispatch import _parse -except ImportError: - try: - # commands.parse moves to cmdutil.parse in 0c61124ad877 - _parse = cmdutil.parse - except AttributeError: - _parse = commands.parse - def _pathto(repo, f, cwd=None): '''kwfiles behaves similar to status, using pathto since 78b6add1f966.''' try: @@ -107,7 +96,7 @@ # commands.parse/cmdutil.parse returned nothing for # "hg diff --rev" before 88803a69b24a due to bug in fancyopts -def _fancyopts(args, options, state): +def fancyopts(args, options, state): '''Fixed fancyopts from 88803a69b24a.''' long = [] short = '' @@ -137,7 +126,19 @@ elif dt[map[opt]] is type(False): state[map[opt]] = True return args -fancyopts.fancyopts = _fancyopts +def findcmd(ui, cmd, table): + '''findcmd has table argument since 18a9fbb5cd78.''' + try: + return findcmd.findcmd(ui, cmd, table) + except TypeError: + return findcmd.findcmd(ui, cmd) +# findcmd in commands until 0c61124ad877 +try: + findcmd.findcmd = cmdutil.findcmd + findcmd.__doc__ = cmdutil.findcmd.__doc__ +except AttributeError: + findcmd.findcmd = commands.findcmd + findcmd.__doc__ = commands.findcmd.__doc__ commands.optionalrepo += ' kwdemo' @@ -477,11 +478,18 @@ This is done for local repos only, and only if there are files configured at all for keyword substitution.''' - nokwcommands = ['add', 'addremove', 'bundle', 'clone', 'copy', 'export', + nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export', 'grep', 'identify', 'incoming', 'init', 'outgoing', 'push', - 'remove', 'rename', 'rollback', 'convert'] + 'remove', 'rename', 'rollback', 'convert') - if not repo.local() or _parse(ui, sys.argv[1:])[0] in nokwcommands: + def _getcmd(): + '''Simplified argument parsing as we are only interested in command.''' + args = fancyopts(sys.argv[1:], commands.globalopts, {}) + if args: + aliases, i = findcmd(ui, args[0], commands.table) + return aliases[0] + + if not repo.local() or _getcmd() in nokwcommands: return inc, exc = [], ['.hgtags']