[PATCH 3 of 3] commands.log.getrenamed simplification

Alexander Solovyov piranha at piranha.org.ua
Fri Oct 17 15:50:03 CDT 2008


# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1224276304 -10800
# Node ID efdd671c2248cb5874f7f4ef8eb103e1c965adff
# Parent  a474e92d37d798557f6ec6ac99639fb6c970ed49
commands.log.getrenamed simplification

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1776,37 +1776,14 @@
         endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1
     else:
         endrev = len(repo)
-    rcache = {}
-    ncache = {}
-    def getrenamed(fn, rev):
-        '''looks up all renames for a file (up to endrev) the first
-        time the file is given. It indexes on the changerev and only
-        parses the manifest if linkrev != changerev.
-        Returns rename info for fn at changerev rev.'''
-        if fn not in rcache:
-            rcache[fn] = {}
-            ncache[fn] = {}
-            fl = repo.file(fn)
-            for i in fl:
-                node = fl.node(i)
-                lr = fl.linkrev(node)
-                renamed = fl.renamed(node)
-                rcache[fn][lr] = renamed
-                if renamed:
-                    ncache[fn][node] = renamed
-                if lr >= endrev:
-                    break
-        if rev in rcache[fn]:
-            return rcache[fn][rev]
 
-        # If linkrev != rev (i.e. rev not found in rcache) fallback to
-        # filectx logic.
-
-        try:
-            return repo[rev][fn].renamed()
-        except revlog.LookupError:
-            pass
-        return None
+    def getrenamed(ctx):
+        for f in ctx.files():
+            if not f in ctx.manifest():
+                continue
+            cp = ctx.filectx(f).renamed()
+            if cp:
+                yield (f, cp[0])
 
     df = False
     if opts["date"]:


More information about the Mercurial-devel mailing list