hgkw/keyword.py
changeset 318 12d26936a315
parent 317 b18631f0dbdc
child 319 2da9ab0bc400
equal deleted inserted replaced
317:b18631f0dbdc 318:12d26936a315
   402     Wraps commit to overwrite configured files with updated
   402     Wraps commit to overwrite configured files with updated
   403     keyword substitutions.
   403     keyword substitutions.
   404     This is done for local repos only, and only if there are
   404     This is done for local repos only, and only if there are
   405     files configured at all for keyword substitution.'''
   405     files configured at all for keyword substitution.'''
   406 
   406 
   407     nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   407     def kwbailout():
   408                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
   408         '''Obtains command via simplified cmdline parsing,
   409                     'remove', 'rename', 'rollback', 'convert')
   409         returns True if keyword expansion not needed.'''
   410 
   410         nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy',
   411     def _getcmd():
   411                         'export', 'grep', 'identify', 'incoming', 'init',
   412         '''Simplified argument parsing as we are only interested in command.'''
   412                         'outgoing', 'push', 'remove', 'rename', 'rollback',
       
   413                         'convert')
   413         args = fancyopts.fancyopts(sys.argv[1:], commands.globalopts, {})
   414         args = fancyopts.fancyopts(sys.argv[1:], commands.globalopts, {})
   414         if args:
   415         if args:
   415             aliases, i = cmdutil.findcmd(ui, args[0], commands.table)
   416             aliases, i = cmdutil.findcmd(ui, args[0], commands.table)
   416             return aliases[0]
   417             return aliases[0] in nokwcommands
   417 
   418 
   418     if not repo.local() or _getcmd() in nokwcommands:
   419     if not repo.local() or kwbailout():
   419         return
   420         return
   420 
   421 
   421     inc, exc = [], ['.hgtags']
   422     inc, exc = [], ['.hgtags']
   422     for pat, opt in ui.configitems('keyword'):
   423     for pat, opt in ui.configitems('keyword'):
   423         if opt != 'ignore':
   424         if opt != 'ignore':