hgkw/kwexpander.py
branchupdatehook
changeset 25 aa3fbe81e9ad
parent 24 1083d250d1b2
child 29 bda83c13da42
equal deleted inserted replaced
24:1083d250d1b2 25:aa3fbe81e9ad
     2 
     2 
     3 from mercurial.i18n import _
     3 from mercurial.i18n import _
     4 from mercurial import util
     4 from mercurial import util
     5 import re
     5 import re
     6 
     6 
     7 # name of keyword encode filter:
       
     8 kwencodefilter = 'hgkwencode'
       
     9 # look for <Dollar>Hg<Dollar>
       
    10 kwtrigger = '%sHg$' % '$'
       
    11 
       
    12 def wwritekw(ui, repo, f, text):
       
    13     '''Writes text with kwupdates keywords to f in working directory.'''
       
    14     ui.note(_('expanding keywords in %s\n' % f))
       
    15 #   # backup file (?)
       
    16 #   absfile = repo.wjoin(f)
       
    17 #   util.copyfile(absfile, absfile+'.kwbak')
       
    18     repo.wfile(f, 'w').write(text)
       
    19 
       
    20 def expandkw(ui, repo, node, cid, candidates, update=False):
     7 def expandkw(ui, repo, node, cid, candidates, update=False):
    21     '''Important: returns False on success, True on failure.'''
     8     '''Important: returns False on success, True on failure.'''
       
     9 
       
    10     # name of keyword encode filter:
       
    11     kwencodefilter = 'hgkwencode'
       
    12 
       
    13     # look for <Dollar>Hg<Dollar>
       
    14     kwtrigger = '%sHg$' % '$'
       
    15 
       
    16     def wwritekw(ui, repo, f, text):
       
    17         '''Writes text with kwupdates keywords to f in working directory.'''
       
    18         ui.note(_('expanding keywords in %s\n' % f))
       
    19     #   # backup file (?)
       
    20     #   absfile = repo.wjoin(f)
       
    21     #   util.copyfile(absfile, absfile+'.kwbak')
       
    22         repo.wfile(f, 'w').write(text)
    22 
    23 
    23     # only check files that have hgkwencode assigned as encode filter
    24     # only check files that have hgkwencode assigned as encode filter
    24     files = []
    25     files = []
    25     # python2.4: files = set()
    26     # python2.4: files = set()
    26     for pat, cmd in repo.ui.configitems('encode'):
    27     for pat, cmd in repo.ui.configitems('encode'):