hgkw/keyword.py
branchsolo-extension
changeset 50 fe891f87a16c
parent 49 5acfe7dc3086
child 51 1ecb6ec5d16b
equal deleted inserted replaced
49:5acfe7dc3086 50:fe891f87a16c
    84             if util.binary(data):
    84             if util.binary(data):
    85                 return data
    85                 return data
    86 
    86 
    87             c = context.filectx(self._repo, self._path, fileid=node,
    87             c = context.filectx(self._repo, self._path, fileid=node,
    88                                  filelog=self)
    88                                  filelog=self)
    89             f = c.path()
    89             if self._path.startswith('.hg'):
    90             if f.startswith('.hg'):
       
    91                 return data
    90                 return data
    92 
    91 
    93             for pat, opt in self._repo.ui.configitems('keyword'):
    92             for pat, opt in self._repo.ui.configitems('keyword'):
    94                 if opt == 'expand':
    93                 if opt == 'expand':
    95                     mf = util.matcher(self._repo.root,
    94                     mf = util.matcher(self._repo.root,
    96                             '', [pat], [], [])[1]
    95                             '', [pat], [], [])[1]
    97                     if mf(f):
    96                     if mf(self._path):
    98 
    97 
    99                         def kwexpander(matchobj):
    98                         def kwexpander(matchobj):
   100                             return kwexpand(matchobj,
    99                             return kwexpand(matchobj,
   101                                     self._repo, c.changectx(), f,
   100                                     self._repo, c.changectx(), self._path,
   102                                     c.date(), c.user())
   101                                     c.date(), c.user())
   103 
   102 
   104                         re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
   103                         re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
   105                         return re_kw.sub(kwexpander, data)
   104                         return re_kw.sub(kwexpander, data)
   106             return data
   105             return data