hgext/keyword.py
branchstable
changeset 49366 288de6f5d724
parent 48946 642e31cb55f0
child 49959 c166b212bdee
equal deleted inserted replaced
49364:e8ea403b1c46 49366:288de6f5d724
    80 Expansions spanning more than one line and incremental expansions,
    80 Expansions spanning more than one line and incremental expansions,
    81 like CVS' $Log$, are not supported. A keyword template map "Log =
    81 like CVS' $Log$, are not supported. A keyword template map "Log =
    82 {desc}" expands to the first line of the changeset description.
    82 {desc}" expands to the first line of the changeset description.
    83 '''
    83 '''
    84 
    84 
    85 
       
    86 from __future__ import absolute_import
       
    87 
    85 
    88 import os
    86 import os
    89 import re
    87 import re
    90 import weakref
    88 import weakref
    91 
    89 
   235     modified = [f for f in wstatus.modified if f in changed]
   233     modified = [f for f in wstatus.modified if f in changed]
   236     added = [f for f in wstatus.added if f in changed]
   234     added = [f for f in wstatus.added if f in changed]
   237     return modified, added
   235     return modified, added
   238 
   236 
   239 
   237 
   240 class kwtemplater(object):
   238 class kwtemplater:
   241     """
   239     """
   242     Sets up keyword templates, corresponding keyword regex, and
   240     Sets up keyword templates, corresponding keyword regex, and
   243     provides keyword substitution functions.
   241     provides keyword substitution functions.
   244     """
   242     """
   245 
   243 
   513         else:
   511         else:
   514             ui.status(_(b'\n\tconfiguration using default cvs keywordset\n'))
   512             ui.status(_(b'\n\tconfiguration using default cvs keywordset\n'))
   515         kwmaps = _defaultkwmaps(ui)
   513         kwmaps = _defaultkwmaps(ui)
   516         if uikwmaps:
   514         if uikwmaps:
   517             ui.status(_(b'\tdisabling current template maps\n'))
   515             ui.status(_(b'\tdisabling current template maps\n'))
   518             for k, v in pycompat.iteritems(kwmaps):
   516             for k, v in kwmaps.items():
   519                 ui.setconfig(b'keywordmaps', k, v, b'keyword')
   517                 ui.setconfig(b'keywordmaps', k, v, b'keyword')
   520     else:
   518     else:
   521         ui.status(_(b'\n\tconfiguration using current keyword template maps\n'))
   519         ui.status(_(b'\n\tconfiguration using current keyword template maps\n'))
   522         if uikwmaps:
   520         if uikwmaps:
   523             kwmaps = dict(uikwmaps)
   521             kwmaps = dict(uikwmaps)
   527     uisetup(ui)
   525     uisetup(ui)
   528     reposetup(ui, repo)
   526     reposetup(ui, repo)
   529     ui.writenoi18n(b'[extensions]\nkeyword =\n')
   527     ui.writenoi18n(b'[extensions]\nkeyword =\n')
   530     demoitems(b'keyword', ui.configitems(b'keyword'))
   528     demoitems(b'keyword', ui.configitems(b'keyword'))
   531     demoitems(b'keywordset', ui.configitems(b'keywordset'))
   529     demoitems(b'keywordset', ui.configitems(b'keywordset'))
   532     demoitems(b'keywordmaps', pycompat.iteritems(kwmaps))
   530     demoitems(b'keywordmaps', kwmaps.items())
   533     keywords = b'$' + b'$\n$'.join(sorted(kwmaps.keys())) + b'$\n'
   531     keywords = b'$' + b'$\n$'.join(sorted(kwmaps.keys())) + b'$\n'
   534     repo.wvfs.write(fn, keywords)
   532     repo.wvfs.write(fn, keywords)
   535     repo[None].add([fn])
   533     repo[None].add([fn])
   536     ui.note(_(b'\nkeywords written to %s:\n') % fn)
   534     ui.note(_(b'\nkeywords written to %s:\n') % fn)
   537     ui.note(keywords)
   535     ui.note(keywords)