[PATCH 6 of 6] revset: precompute _follow()

Patrick Mezard patrick at mezard.eu
Tue May 8 15:58:11 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1336510344 -7200
# Node ID b4db2ee7236b9b2d0b4afbb8fcb3808a000a38b3
# Parent  b6067d31061796b5ea04499fd38b164699225770
revset: precompute _follow()

On mercurial repository:

                             first line    total
  * hg log --follow mercurial/commands.py
  2.2                            0.145s   0.523s
  before                         0.409s   2.743s
  after                          0.190s   0.530s

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -548,6 +548,7 @@
     """
     return limit(repo, subset, x)
 
+ at precomputed
 def _follow(repo, subset, x, name, followfirst=False):
     l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name)
     c = repo['.']
@@ -563,8 +564,11 @@
     else:
         s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()])
 
-    return [r for r in subset if r in s]
+    def fn(repo, subset, x):
+        return [r for r in subset if r in s]
+    return fn
 
+ at precomputed
 def follow(repo, subset, x):
     """``follow([file])``
     An alias for ``::.`` (ancestors of the working copy's first parent).
@@ -573,6 +577,7 @@
     """
     return _follow(repo, subset, x, 'follow')
 
+ at precomputed
 def _followfirst(repo, subset, x):
     # ``followfirst([file])``
     # Like ``follow([file])`` but follows only the first parent of


More information about the Mercurial-devel mailing list