hgkw/keyword.py
changeset 292 783c1310e20f
parent 290 b05795ad5632
child 293 a7d568671575
equal deleted inserted replaced
290:b05795ad5632 292:783c1310e20f
    78 Caveat: "hg import" fails if the patch context contains an active
    78 Caveat: "hg import" fails if the patch context contains an active
    79         keyword. In that case run "hg kwshrink", and then reimport.
    79         keyword. In that case run "hg kwshrink", and then reimport.
    80         Or, better, use bundle/unbundle to share changes.
    80         Or, better, use bundle/unbundle to share changes.
    81 '''
    81 '''
    82 
    82 
    83 from mercurial import commands, cmdutil, context, dispatch
    83 from mercurial import commands, cmdutil, context, fancyopts
    84 from mercurial import filelog, localrepo, revlog, templater, util
    84 from mercurial import filelog, localrepo, revlog, templater, util
    85 from mercurial.i18n import _
    85 from mercurial.i18n import _
    86 import re, shutil, sys, tempfile, time
    86 import re, shutil, sys, tempfile, time
    87 
    87 
    88 commands.optionalrepo += ' kwdemo'
    88 commands.optionalrepo += ' kwdemo'
   392     Wraps commit to overwrite configured files with updated
   392     Wraps commit to overwrite configured files with updated
   393     keyword substitutions.
   393     keyword substitutions.
   394     This is done for local repos only, and only if there are
   394     This is done for local repos only, and only if there are
   395     files configured at all for keyword substitution.'''
   395     files configured at all for keyword substitution.'''
   396 
   396 
   397     nokwcommands = ['add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   397     nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   398                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
   398                     'grep', 'identify', 'incoming', 'init', 'outgoing', 'push',
   399                     'remove', 'rename', 'rollback', 'convert']
   399                     'remove', 'rename', 'rollback', 'convert')
   400 
   400 
   401     if (not repo.local() or
   401     def _getcmd():
   402         dispatch._parse(ui, sys.argv[1:])[0] in nokwcommands):
   402         '''Simplified argument parsing as we are only interested in command.'''
       
   403         args = fancyopts.fancyopts(sys.argv[1:], commands.globalopts, {})
       
   404         if args:
       
   405             aliases, i = cmdutil.findcmd(ui, args[0], commands.table)
       
   406             return aliases[0]
       
   407 
       
   408     if not repo.local() or _getcmd() in nokwcommands:
   403         return
   409         return
   404 
   410 
   405     inc, exc = [], ['.hgtags']
   411     inc, exc = [], ['.hgtags']
   406     for pat, opt in ui.configitems('keyword'):
   412     for pat, opt in ui.configitems('keyword'):
   407         if opt != 'ignore':
   413         if opt != 'ignore':