hgkw/keyword.py
changeset 231 95fa2165e4eb
parent 230 9fe9a9839387
child 232 030712a46eb9
equal deleted inserted replaced
230:9fe9a9839387 231:95fa2165e4eb
    88 # backwards compatibility hacks
    88 # backwards compatibility hacks
    89 
    89 
    90 try:
    90 try:
    91     # cmdutil.parse moves to dispatch._parse in 18a9fbb5cd78
    91     # cmdutil.parse moves to dispatch._parse in 18a9fbb5cd78
    92     from mercurial import dispatch
    92     from mercurial import dispatch
    93     __parse = dispatch._parse
    93     _parse = dispatch._parse
    94 except ImportError:
    94 except ImportError:
    95     try:
    95     try:
    96         # commands.parse moves to cmdutil.parse in 0c61124ad877
    96         # commands.parse moves to cmdutil.parse in 0c61124ad877
    97         __parse = cmdutil.parse
    97         _parse = cmdutil.parse
    98     except AttributeError:
    98     except AttributeError:
    99         __parse = commands.parse
    99         _parse = commands.parse
   100 
   100 
   101 try:
   101 try:
   102     # bail_if_changed moves from commands to cmdutil in 0c61124ad877
   102     # bail_if_changed moves from commands to cmdutil in 0c61124ad877
   103     _bail_if_changed = cmdutil.bail_if_changed
   103     bail_if_changed = cmdutil.bail_if_changed
   104 except AttributeError:
   104 except AttributeError:
   105     _bail_if_changed = commands.bail_if_changed
   105     bail_if_changed = commands.bail_if_changed
   106 
   106 
   107 # commands.parse/cmdutil.parse returned nothing for
   107 # commands.parse/cmdutil.parse returned nothing for
   108 # "hg diff --rev" before 88803a69b24a due to bug in fancyopts
   108 # "hg diff --rev" before 88803a69b24a due to bug in fancyopts
   109 def _fancyopts(args, options, state):
   109 def _fancyopts(args, options, state):
   110     '''Fixed fancyopts from 88803a69b24a.'''
   110     '''Fixed fancyopts from 88803a69b24a.'''
   313     '''Expands/shrinks keywords in working directory.'''
   313     '''Expands/shrinks keywords in working directory.'''
   314     wlock = lock = None
   314     wlock = lock = None
   315     try:
   315     try:
   316         wlock = repo.wlock()
   316         wlock = repo.wlock()
   317         lock = repo.lock()
   317         lock = repo.lock()
   318         _bail_if_changed(repo)
   318         bail_if_changed(repo)
   319         ctx = repo.changectx()
   319         ctx = repo.changectx()
   320         if not ctx:
   320         if not ctx:
   321             raise hg.RepoError(_('no revision checked out'))
   321             raise hg.RepoError(_('no revision checked out'))
   322         kwfmatcher = _keywordmatcher(ui, repo)
   322         kwfmatcher = _keywordmatcher(ui, repo)
   323         if kwfmatcher is None:
   323         if kwfmatcher is None:
   440 
   440 
   441     nokwcommands = ['add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   441     nokwcommands = ['add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   442                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
   442                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
   443                     'remove', 'rename', 'rollback']
   443                     'remove', 'rename', 'rollback']
   444 
   444 
   445     if not repo.local() or __parse(ui, sys.argv[1:])[0] in nokwcommands:
   445     if not repo.local() or _parse(ui, sys.argv[1:])[0] in nokwcommands:
   446         return
   446         return
   447 
   447 
   448     kwfmatcher = _keywordmatcher(ui, repo)
   448     kwfmatcher = _keywordmatcher(ui, repo)
   449     if kwfmatcher is None:
   449     if kwfmatcher is None:
   450         return
   450         return