hgkw/keyword.py
branchsolo-extension
changeset 71 f7a2a246740c
parent 69 4c5d9635b517
child 72 28455872cb0e
equal deleted inserted replaced
70:f5818ce4c2bd 71:f7a2a246740c
   244                         self.dirstate.forget(removed)
   244                         self.dirstate.forget(removed)
   245 
   245 
   246                 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
   246                 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
   247                 return n
   247                 return n
   248 
   248 
   249     
       
   250     class kwfilelog(filelog.filelog):
   249     class kwfilelog(filelog.filelog):
   251         def __init__(self, opener, path, repo,
   250         def __init__(self, opener, path, repo,
   252                      defversion=revlog.REVLOG_DEFAULT_VERSION):
   251                      defversion=revlog.REVLOG_DEFAULT_VERSION):
   253             super(kwfilelog, self).__init__(opener, path, defversion)
   252             super(kwfilelog, self).__init__(opener, path, defversion)
   254             self._repo = repo
   253             self._repo = repo
   262                 return re_kw.sub(lambda m:
   261                 return re_kw.sub(lambda m:
   263                         kwexpand(m, self._repo, self._path,
   262                         kwexpand(m, self._repo, self._path,
   264                             fileid=node, filelog=self), data)
   263                             fileid=node, filelog=self), data)
   265             return data
   264             return data
   266 
   265 
   267         def size(self, rev):
       
   268             '''Overrides filelog's size() to use kwfilelog.read().'''
       
   269             node = revlog.node(self, rev)
       
   270             if super(kwfilelog, self).renamed(node):
       
   271                 return len(self.read(node))
       
   272             return revlog.size(self, rev)
       
   273 
       
   274         def cmp(self, node, text):
   266         def cmp(self, node, text):
   275             '''Overrides filelog's cmp() to use kwfilelog.read().'''
   267             '''Removes keyword substitution for comparison.'''
   276             if super(kwfilelog, self).renamed(node):
   268             if not util.binary(text):
   277                 t2 = self.read(node)
   269                 text = re_kw.sub(r'$\1$', text)
   278                 return t2 != text
   270             return super(kwfilelog, self).cmp(node, text)
   279 
   271 
   280     filelog.filelog = kwfilelog
   272     filelog.filelog = kwfilelog
   281     repo.__class__ = kwrepo
   273     repo.__class__ = kwrepo