mercurial/commands.py
changeset 9916 3d718761157b
parent 9901 cb2a1836c50a
child 9953 0347eb4d2236
child 9982 ddc899096b7b
equal deleted inserted replaced
9915:806e6b6cb8d8 9916:3d718761157b
  2015     if opts.get('copies') and opts.get('rev'):
  2015     if opts.get('copies') and opts.get('rev'):
  2016         endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
  2016         endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
  2017     else:
  2017     else:
  2018         endrev = len(repo)
  2018         endrev = len(repo)
  2019     rcache = {}
  2019     rcache = {}
  2020     ncache = {}
       
  2021     def getrenamed(fn, rev):
  2020     def getrenamed(fn, rev):
  2022         '''looks up all renames for a file (up to endrev) the first
  2021         '''looks up all renames for a file (up to endrev) the first
  2023         time the file is given. It indexes on the changerev and only
  2022         time the file is given. It indexes on the changerev and only
  2024         parses the manifest if linkrev != changerev.
  2023         parses the manifest if linkrev != changerev.
  2025         Returns rename info for fn at changerev rev.'''
  2024         Returns rename info for fn at changerev rev.'''
  2026         if fn not in rcache:
  2025         if fn not in rcache:
  2027             rcache[fn] = {}
  2026             rcache[fn] = {}
  2028             ncache[fn] = {}
       
  2029             fl = repo.file(fn)
  2027             fl = repo.file(fn)
  2030             for i in fl:
  2028             for i in fl:
  2031                 node = fl.node(i)
       
  2032                 lr = fl.linkrev(i)
  2029                 lr = fl.linkrev(i)
  2033                 renamed = fl.renamed(node)
  2030                 renamed = fl.renamed(fl.node(i))
  2034                 rcache[fn][lr] = renamed
  2031                 rcache[fn][lr] = renamed
  2035                 if renamed:
       
  2036                     ncache[fn][node] = renamed
       
  2037                 if lr >= endrev:
  2032                 if lr >= endrev:
  2038                     break
  2033                     break
  2039         if rev in rcache[fn]:
  2034         if rev in rcache[fn]:
  2040             return rcache[fn][rev]
  2035             return rcache[fn][rev]
  2041 
  2036 
  2042         # If linkrev != rev (i.e. rev not found in rcache) fallback to
  2037         # If linkrev != rev (i.e. rev not found in rcache) fallback to
  2043         # filectx logic.
  2038         # filectx logic.
  2044 
       
  2045         try:
  2039         try:
  2046             return repo[rev][fn].renamed()
  2040             return repo[rev][fn].renamed()
  2047         except error.LookupError:
  2041         except error.LookupError:
  2048             pass
  2042             return None
  2049         return None
       
  2050 
  2043 
  2051     df = False
  2044     df = False
  2052     if opts["date"]:
  2045     if opts["date"]:
  2053         df = util.matchdate(opts["date"])
  2046         df = util.matchdate(opts["date"])
  2054 
  2047