mercurial/context.py
changeset 15528 a84698badf0b
parent 15453 cff509500a24
child 15703 2a48422e27f6
equal deleted inserted replaced
15527:9926aab3d0b5 15528:a84698badf0b
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from node import nullid, nullrev, short, hex
     8 from node import nullid, nullrev, short, hex
     9 from i18n import _
     9 from i18n import _
    10 import ancestor, bdiff, error, util, scmutil, subrepo, patch, encoding
    10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding
    11 import match as matchmod
    11 import match as matchmod
    12 import os, errno, stat
    12 import os, errno, stat
    13 
    13 
    14 propertycache = util.propertycache
    14 propertycache = util.propertycache
    15 
    15 
   431         # hard for renames
   431         # hard for renames
   432         c = self._filelog.children(self._filenode)
   432         c = self._filelog.children(self._filenode)
   433         return [filectx(self._repo, self._path, fileid=x,
   433         return [filectx(self._repo, self._path, fileid=x,
   434                         filelog=self._filelog) for x in c]
   434                         filelog=self._filelog) for x in c]
   435 
   435 
   436     def annotate(self, follow=False, linenumber=None):
   436     def annotate(self, follow=False, linenumber=None, diffopts=None):
   437         '''returns a list of tuples of (ctx, line) for each line
   437         '''returns a list of tuples of (ctx, line) for each line
   438         in the file, where ctx is the filectx of the node where
   438         in the file, where ctx is the filectx of the node where
   439         that line was last changed.
   439         that line was last changed.
   440         This returns tuples of ((ctx, linenumber), line) for each line,
   440         This returns tuples of ((ctx, linenumber), line) for each line,
   441         if "linenumber" parameter is NOT "None".
   441         if "linenumber" parameter is NOT "None".
   458         decorate = (((linenumber is None) and decorate_compat) or
   458         decorate = (((linenumber is None) and decorate_compat) or
   459                     (linenumber and with_linenumber) or
   459                     (linenumber and with_linenumber) or
   460                     without_linenumber)
   460                     without_linenumber)
   461 
   461 
   462         def pair(parent, child):
   462         def pair(parent, child):
   463             for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]):
   463             blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
   464                 child[0][b1:b2] = parent[0][a1:a2]
   464                                      refine=True)
       
   465             for (a1, a2, b1, b2), t in blocks:
       
   466                 # Changed blocks ('!') or blocks made only of blank lines ('~')
       
   467                 # belong to the child.
       
   468                 if t == '=':
       
   469                     child[0][b1:b2] = parent[0][a1:a2]
   465             return child
   470             return child
   466 
   471 
   467         getlog = util.lrucachefunc(lambda x: self._repo.file(x))
   472         getlog = util.lrucachefunc(lambda x: self._repo.file(x))
   468         def getctx(path, fileid):
   473         def getctx(path, fileid):
   469             log = path == self._path and self._filelog or getlog(path)
   474             log = path == self._path and self._filelog or getlog(path)