mercurial/templatekw.py
changeset 41781 e9b9ee9af4a9
parent 41772 52d4cb162902
child 42371 b47e9712000b
equal deleted inserted replaced
41780:18f619d3b1bb 41781:e9b9ee9af4a9
   102             todo.extend(p.rev() for p in ctx.parents())
   102             todo.extend(p.rev() for p in ctx.parents())
   103             continue
   103             continue
   104         latesttags[rev] = pdate, pdist + 1, ptag
   104         latesttags[rev] = pdate, pdist + 1, ptag
   105     return latesttags[rev]
   105     return latesttags[rev]
   106 
   106 
   107 def getrenamedfn(repo, endrev=None):
       
   108     rcache = {}
       
   109     if endrev is None:
       
   110         endrev = len(repo)
       
   111 
       
   112     def getrenamed(fn, rev):
       
   113         '''looks up all renames for a file (up to endrev) the first
       
   114         time the file is given. It indexes on the changerev and only
       
   115         parses the manifest if linkrev != changerev.
       
   116         Returns rename info for fn at changerev rev.'''
       
   117         if fn not in rcache:
       
   118             rcache[fn] = {}
       
   119             fl = repo.file(fn)
       
   120             for i in fl:
       
   121                 lr = fl.linkrev(i)
       
   122                 renamed = fl.renamed(fl.node(i))
       
   123                 rcache[fn][lr] = renamed and renamed[0]
       
   124                 if lr >= endrev:
       
   125                     break
       
   126         if rev in rcache[fn]:
       
   127             return rcache[fn][rev]
       
   128 
       
   129         # If linkrev != rev (i.e. rev not found in rcache) fallback to
       
   130         # filectx logic.
       
   131         try:
       
   132             return repo[rev][fn].copysource()
       
   133         except error.LookupError:
       
   134             return None
       
   135 
       
   136     return getrenamed
       
   137 
       
   138 def getlogcolumns():
   107 def getlogcolumns():
   139     """Return a dict of log column labels"""
   108     """Return a dict of log column labels"""
   140     _ = pycompat.identity  # temporarily disable gettext
   109     _ = pycompat.identity  # temporarily disable gettext
   141     # i18n: column positioning for "hg log"
   110     # i18n: column positioning for "hg log"
   142     columns = _('bookmark:    %s\n'
   111     columns = _('bookmark:    %s\n'
   341     ctx = context.resource(mapping, 'ctx')
   310     ctx = context.resource(mapping, 'ctx')
   342     cache = context.resource(mapping, 'cache')
   311     cache = context.resource(mapping, 'cache')
   343     copies = context.resource(mapping, 'revcache').get('copies')
   312     copies = context.resource(mapping, 'revcache').get('copies')
   344     if copies is None:
   313     if copies is None:
   345         if 'getrenamed' not in cache:
   314         if 'getrenamed' not in cache:
   346             cache['getrenamed'] = getrenamedfn(repo)
   315             cache['getrenamed'] = scmutil.getrenamedfn(repo)
   347         copies = []
   316         copies = []
   348         getrenamed = cache['getrenamed']
   317         getrenamed = cache['getrenamed']
   349         for fn in ctx.files():
   318         for fn in ctx.files():
   350             rename = getrenamed(fn, ctx.rev())
   319             rename = getrenamed(fn, ctx.rev())
   351             if rename:
   320             if rename: