revset: fixed bug where revset returning order was being changed
authorLucas Moscovicz <lmoscovicz@fb.com>
Fri, 07 Feb 2014 15:01:33 -0800
changeset 20393 b0638b5b004d
parent 20392 d4f804caa0ed
child 20394 a817964e7fdf
revset: fixed bug where revset returning order was being changed Some revsets were innecesarily turning the subset into a set before iterating over it. This led to returning order changing in some cases.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Mon Feb 03 18:36:00 2014 -0500
+++ b/mercurial/revset.py	Fri Feb 07 15:01:33 2014 -0800
@@ -310,8 +310,7 @@
     if not args:
         return baseset([])
     s = set(_revancestors(repo, args, followfirst)) | set(args)
-    ss = subset.set()
-    return baseset([r for r in ss if r in s])
+    return baseset([r for r in subset if r in s])
 
 def ancestors(repo, subset, x):
     """``ancestors(set)``
@@ -339,8 +338,7 @@
         for i in range(n):
             r = cl.parentrevs(r)[0]
         ps.add(r)
-    s = subset.set()
-    return baseset([r for r in s if r in ps])
+    return baseset([r for r in subset if r in ps])
 
 def author(repo, subset, x):
     """``author(string)``
@@ -367,8 +365,7 @@
     # i18n: "bisect" is a keyword
     status = getstring(x, _("bisect requires a string")).lower()
     state = set(hbisect.get(repo, status))
-    s = subset.set()
-    return baseset([r for r in s if r in state])
+    return baseset([r for r in subset if r in state])
 
 # Backward-compatibility
 # - no help entry so that we do not advertise it any more
@@ -411,8 +408,7 @@
 
     bms = set([repo[r].rev()
                for r in repo._bookmarks.values()])
-    s = subset.set()
-    return baseset([r for r in s if r in bms])
+    return baseset([r for r in subset if r in bms])
 
 def branch(repo, subset, x):
     """``branch(string or set)``
@@ -607,8 +603,7 @@
     if not args:
         return baseset([])
     s = set(_revdescendants(repo, args, followfirst)) | set(args)
-    ss = subset.set()
-    return baseset([r for r in ss if r in s])
+    return baseset([r for r in subset if r in s])
 
 def descendants(repo, subset, x):
     """``descendants(set)``
@@ -748,8 +743,7 @@
                 for fr in fl:
                     s.add(fl.linkrev(fr))
 
-    ss = subset.set()
-    return baseset([r for r in ss if r in s])
+    return baseset([r for r in subset if r in s])
 
 def first(repo, subset, x):
     """``first(set, [n])``
@@ -772,8 +766,7 @@
     else:
         s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()])
 
-    ss = subset.set()
-    return baseset([r for r in ss if r in s])
+    return baseset([r for r in subset if r in s])
 
 def follow(repo, subset, x):
     """``follow([file])``
@@ -902,8 +895,7 @@
     hs = set()
     for b, ls in repo.branchmap().iteritems():
         hs.update(repo[h].rev() for h in ls)
-    s = subset.set()
-    return baseset([r for r in s if r in hs])
+    return baseset([r for r in subset if r in hs])
 
 def heads(repo, subset, x):
     """``heads(set)``
@@ -1085,8 +1077,7 @@
             src = prev
 
     o = set([_firstsrc(r) for r in args])
-    s = subset.set()
-    return baseset([r for r in s if r in o])
+    return baseset([r for r in subset if r in o])
 
 def outgoing(repo, subset, x):
     """``outgoing([path])``
@@ -1109,8 +1100,7 @@
     repo.ui.popbuffer()
     cl = repo.changelog
     o = set([cl.rev(r) for r in outgoing.missing])
-    s = subset.set()
-    return baseset([r for r in s if r in o])
+    return baseset([r for r in subset if r in o])
 
 def p1(repo, subset, x):
     """``p1([set])``
@@ -2070,10 +2060,9 @@
         return baseset(self.set() - s)
 
     def __and__(self, x):
-        s = self.set()
         if isinstance(x, baseset):
             x = x.set()
-        return baseset([y for y in s if y in x])
+        return baseset([y for y in self if y in x])
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()
--- a/tests/test-revset.t	Mon Feb 03 18:36:00 2014 -0500
+++ b/tests/test-revset.t	Fri Feb 07 15:01:33 2014 -0800
@@ -414,6 +414,16 @@
   2
   1
   0
+  $ log '1:: and reverse(all())'
+  9
+  8
+  7
+  6
+  5
+  4
+  3
+  2
+  1
   $ log 'rev(5)'
   5
   $ log 'sort(limit(reverse(all()), 3))'