hgkw/keyword.py
changeset 301 e92c6762e2be
parent 300 583efc0983f1
child 304 815dc4a04296
equal deleted inserted replaced
300:583efc0983f1 301:e92c6762e2be
   125         if self.t:
   125         if self.t:
   126             templater.common_filters['utcdate'] = utcdate
   126             templater.common_filters['utcdate'] = utcdate
   127             self.t = cmdutil.changeset_templater(self.ui, self.repo,
   127             self.t = cmdutil.changeset_templater(self.ui, self.repo,
   128                                                  False, '', False)
   128                                                  False, '', False)
   129 
   129 
   130     def kwsub(self, mobj):
       
   131         '''Substitutes keyword using corresponding template.'''
       
   132         kw = mobj.group(1)
       
   133         self.t.use_template(self.templates[kw])
       
   134         self.ui.pushbuffer()
       
   135         self.t.show(changenode=self.node, root=self.repo.root, file=self.path)
       
   136         keywordsub = templater.firstline(self.ui.popbuffer())
       
   137         return '$%s: %s $' % (kw, keywordsub)
       
   138 
       
   139     def substitute(self, node, data, subfunc):
   130     def substitute(self, node, data, subfunc):
   140         '''Obtains node if missing, and calls given substitution function.'''
   131         '''Obtains node if missing, and calls given substitution function.'''
   141         if not self.node:
   132         if not self.node:
   142             c = context.filectx(self.repo, self.path, fileid=node)
   133             c = context.filectx(self.repo, self.path, fileid=node)
   143             self.node = c.node()
   134             self.node = c.node()
   144         return subfunc(self.kwsub, data)
   135 
       
   136         def kwsub(mobj):
       
   137             '''Substitutes keyword using corresponding template.'''
       
   138             kw = mobj.group(1)
       
   139             self.t.use_template(self.templates[kw])
       
   140             self.ui.pushbuffer()
       
   141             self.t.show(changenode=self.node,
       
   142                         root=self.repo.root, file=self.path)
       
   143             return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer()))
       
   144 
       
   145         return subfunc(kwsub, data)
   145 
   146 
   146     def expand(self, node, data):
   147     def expand(self, node, data):
   147         '''Returns data with keywords expanded.'''
   148         '''Returns data with keywords expanded.'''
   148         if util.binary(data):
   149         if util.binary(data):
   149             return data
   150             return data