diff mercurial/revset.py @ 14153:f8047a059ca0

revset: avoid over-aggresive optimizations of non-filtering functions (issue2549) When limit, last, min and max were evaluated they worked on a reduced set in the wrong way. Now they work on an unrestricted set (the whole repo) and get limited later on.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 01 May 2011 17:35:05 +0200
parents 9f5a0acb0056
children 30273f0c776b
line wrap: on
line diff
--- a/mercurial/revset.py	Sun May 01 17:35:05 2011 +0200
+++ b/mercurial/revset.py	Sun May 01 17:35:05 2011 +0200
@@ -468,7 +468,9 @@
     except ValueError:
         # i18n: "limit" is a keyword
         raise error.ParseError(_("limit expects a number"))
-    return getset(repo, subset, l[0])[:lim]
+    ss = set(subset)
+    os = getset(repo, range(len(repo)), l[0])[:lim]
+    return [r for r in os if r in ss]
 
 def last(repo, subset, x):
     """``last(set, n)``
@@ -482,15 +484,17 @@
     except ValueError:
         # i18n: "last" is a keyword
         raise error.ParseError(_("last expects a number"))
-    return getset(repo, subset, l[0])[-lim:]
+    ss = set(subset)
+    os = getset(repo, range(len(repo)), l[0])[-lim:]
+    return [r for r in os if r in ss]
 
 def maxrev(repo, subset, x):
     """``max(set)``
     Changeset with highest revision number in set.
     """
-    s = getset(repo, subset, x)
-    if s:
-        m = max(s)
+    os = getset(repo, range(len(repo)), x)
+    if os:
+        m = max(os)
         if m in subset:
             return [m]
     return []
@@ -508,9 +512,9 @@
     """``min(set)``
     Changeset with lowest revision number in set.
     """
-    s = getset(repo, subset, x)
-    if s:
-        m = min(s)
+    os = getset(repo, range(len(repo)), x)
+    if os:
+        m = min(os)
         if m in subset:
             return [m]
     return []