hgkw/keyword.py
branchself_initializing_hook
changeset 83 05e50378c6e8
parent 82 9bf0f7db5928
child 84 f8f0296775ad
equal deleted inserted replaced
82:9bf0f7db5928 83:05e50378c6e8
    66     configured in keyword section in hgrc.'''
    66     configured in keyword section in hgrc.'''
    67     files = [f for f in files if not f.startswith('.hg')]
    67     files = [f for f in files if not f.startswith('.hg')]
    68     if not files:
    68     if not files:
    69         return []
    69         return []
    70     candidates = []
    70     candidates = []
    71     fmatchers = [util.matcher(repo.root, '', [pat], [], [])[1]
    71     kwfmatchers = [util.matcher(repo.root, '', [pat], [], [])[1]
    72             for pat, opt in ui.configitems('keyword')
    72             for pat, opt in ui.configitems('keyword') if opt == 'expand']
    73             if opt == 'expand']
       
    74     for f in files:
    73     for f in files:
    75         for mf in fmatchers:
    74         for mf in kwfmatchers:
    76             if mf(f):
    75             if mf(f):
    77                 candidates.append(f)
    76                 candidates.append(f)
    78                 break
    77                 break
    79     return candidates
    78     return candidates
    80 
    79 
   157 
   156 
   158     for f in kwfmatches(ui, repo, modified+added):
   157     for f in kwfmatches(ui, repo, modified+added):
   159         data = repo.wfile(f).read()
   158         data = repo.wfile(f).read()
   160         if not util.binary(data):
   159         if not util.binary(data):
   161             data, kwct = re_kw.subn(lambda m:
   160             data, kwct = re_kw.subn(lambda m:
   162                     kwexpand(m, repo, f, changeid=args['node']),
   161                     kwexpand(m, repo, f, changeid=args['node']), data)
   163                     data)
       
   164             if kwct:
   162             if kwct:
   165                 ui.debug(_('overwriting %s expanding keywords\n' % f))
   163                 ui.debug(_('overwriting %s expanding keywords\n' % f))
   166                 repo.wfile(f, 'w').write(data)
   164                 repo.wfile(f, 'w').write(data)