hgkw/keyword.py
changeset 816 00570f650792
parent 815 1c9959ca570a
child 818 b742a071ad9c
equal deleted inserted replaced
815:1c9959ca570a 816:00570f650792
    80 Expansions spanning more than one line and incremental expansions,
    80 Expansions spanning more than one line and incremental expansions,
    81 like CVS' $Log$, are not supported. A keyword template map "Log =
    81 like CVS' $Log$, are not supported. A keyword template map "Log =
    82 {desc}" expands to the first line of the changeset description.
    82 {desc}" expands to the first line of the changeset description.
    83 '''
    83 '''
    84 
    84 
    85 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
    85 from mercurial import commands, cmdutil, dispatch, filelog, extensions
    86 from mercurial import patch, localrepo, templater, templatefilters, util, match
    86 from mercurial import localrepo, match, patch, templatefilters, templater, util
    87 from mercurial.hgweb import webcommands
    87 from mercurial.hgweb import webcommands
    88 from mercurial.i18n import _
    88 from mercurial.i18n import _
    89 import re, shutil, tempfile
    89 import re, shutil, tempfile
    90 
    90 
    91 commands.optionalrepo += ' kwdemo'
    91 commands.optionalrepo += ' kwdemo'
   261         self.path = path
   261         self.path = path
   262 
   262 
   263     def read(self, node):
   263     def read(self, node):
   264         '''Expands keywords when reading filelog.'''
   264         '''Expands keywords when reading filelog.'''
   265         data = super(kwfilelog, self).read(node)
   265         data = super(kwfilelog, self).read(node)
       
   266         if self.renamed(node):
       
   267             return data
   266         return self.kwt.expand(self.path, node, data)
   268         return self.kwt.expand(self.path, node, data)
   267 
   269 
   268     def add(self, text, meta, tr, link, p1=None, p2=None):
   270     def add(self, text, meta, tr, link, p1=None, p2=None):
   269         '''Removes keyword substitutions when adding to filelog.'''
   271         '''Removes keyword substitutions when adding to filelog.'''
   270         text = self.kwt.shrink(self.path, text)
   272         text = self.kwt.shrink(self.path, text)
   271         return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
   273         return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
   272 
   274 
   273     def cmp(self, node, text):
   275     def cmp(self, node, text):
   274         '''Removes keyword substitutions for comparison.'''
   276         '''Removes keyword substitutions for comparison.'''
   275         text = self.kwt.shrink(self.path, text)
   277         text = self.kwt.shrink(self.path, text)
   276         if self.renamed(node):
   278         return super(kwfilelog, self).cmp(node, text)
   277             t2 = super(kwfilelog, self).read(node)
       
   278             return t2 != text
       
   279         return revlog.revlog.cmp(self, node, text)
       
   280 
   279 
   281 def _status(ui, repo, kwt, *pats, **opts):
   280 def _status(ui, repo, kwt, *pats, **opts):
   282     '''Bails out if [keyword] configuration is not active.
   281     '''Bails out if [keyword] configuration is not active.
   283     Returns status of working directory.'''
   282     Returns status of working directory.'''
   284     if kwt:
   283     if kwt: