hgkw/keyword.py
branchstable
changeset 708 676de4ffd778
parent 702 c118a9c5ca24
child 710 2f341cf2268d
equal deleted inserted replaced
705:0cb61a4f5c50 708:676de4ffd778
   133         escaped = map(re.escape, self.templates.keys())
   133         escaped = map(re.escape, self.templates.keys())
   134         kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
   134         kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
   135         self.re_kw = re.compile(kwpat)
   135         self.re_kw = re.compile(kwpat)
   136 
   136 
   137         templatefilters.filters['utcdate'] = utcdate
   137         templatefilters.filters['utcdate'] = utcdate
   138         self.ct = cmdutil.changeset_templater(self.ui, self.repo,
       
   139                                               False, None, '', False)
       
   140 
   138 
   141     def substitute(self, data, path, ctx, subfunc):
   139     def substitute(self, data, path, ctx, subfunc):
   142         '''Replaces keywords in data with expanded template.'''
   140         '''Replaces keywords in data with expanded template.'''
   143         def kwsub(mobj):
   141         def kwsub(mobj):
   144             kw = mobj.group(1)
   142             kw = mobj.group(1)
       
   143             self.ct = cmdutil.changeset_templater(self.ui, self.repo,
       
   144                                                   False, None, '', False)
   145             self.ct.use_template(self.templates[kw])
   145             self.ct.use_template(self.templates[kw])
   146             self.ui.pushbuffer()
   146             self.ui.pushbuffer()
   147             self.ct.show(ctx, root=self.repo.root, file=path)
   147             self.ct.show(ctx, root=self.repo.root, file=path)
   148             ekw = templatefilters.firstline(self.ui.popbuffer())
   148             ekw = templatefilters.firstline(self.ui.popbuffer())
   149             return '$%s: %s $' % (kw, ekw)
   149             return '$%s: %s $' % (kw, ekw)