hgkw/keyword.py
branchself_initializing_hook
changeset 93 9f70f953dd3b
parent 92 3c7c187e4001
child 94 d34486cc99b0
child 95 9e4cbe64fb4f
equal deleted inserted replaced
92:3c7c187e4001 93:9f70f953dd3b
    58             if mf(f):
    58             if mf(f):
    59                 candidates.append(f)
    59                 candidates.append(f)
    60                 break
    60                 break
    61     return candidates
    61     return candidates
    62 
    62 
    63 def utc(hgdate):
    63 def utcdate(date):
    64     '''Returns hgdate in cvs-like UTC format.'''
    64     '''Returns hgdate in cvs-like UTC format.'''
    65     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(hgdate[0]))
    65     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
    66 
    66 
    67 
    67 
    68 class kwfilectx(context.filectx):
    68 class kwfilectx(context.filectx):
    69     '''
    69     '''
    70     Provides keyword expansion functions based on file context.
    70     Provides keyword expansion functions based on file context.
    74     def Revision(self):
    74     def Revision(self):
    75         return str(self.changectx())
    75         return str(self.changectx())
    76     def Author(self):
    76     def Author(self):
    77         return util.shortuser(self.user())
    77         return util.shortuser(self.user())
    78     def Date(self):
    78     def Date(self):
    79         return utc(self.date())
    79         return utcdate(self.date())
    80     def RCSFile(self):
    80     def RCSFile(self):
    81         return os.path.basename(self._path)+',v'
    81         return os.path.basename(self._path)+',v'
    82     def Source(self):
    82     def Source(self):
    83         return self._repo.wjoin(self._path)+',v'
    83         return self._repo.wjoin(self._path)+',v'
    84     def Header(self):
    84     def Header(self):
   132         def add(self, text, meta, tr, link, p1=None, p2=None):
   132         def add(self, text, meta, tr, link, p1=None, p2=None):
   133             '''Removes keyword substitutions when adding to filelog.'''
   133             '''Removes keyword substitutions when adding to filelog.'''
   134             if self.iskwcandidate(text):
   134             if self.iskwcandidate(text):
   135                 text = re_kw.sub(r'$\1$', text)
   135                 text = re_kw.sub(r'$\1$', text)
   136             return super(kwfilelog, self).add(text,
   136             return super(kwfilelog, self).add(text,
   137                     meta, tr, link, p1=None, p2=None)
   137                     meta, tr, link, p1=p1, p2=p2)
   138 
   138 
   139         def cmp(self, node, text):
   139         def cmp(self, node, text):
   140             '''Removes keyword substitutions for comparison.'''
   140             '''Removes keyword substitutions for comparison.'''
   141             if self.iskwcandidate(text):
   141             if self.iskwcandidate(text):
   142                 text = re_kw.sub(r'$\1$', text)
   142                 text = re_kw.sub(r'$\1$', text)