revset: make matching() preserve input revision order stable
authorPatrick Mezard <patrick@mezard.eu>
Wed, 09 May 2012 18:45:14 +0200
branchstable
changeset 16640 592e0beee8b0
parent 16639 00290bd359fe
child 16641 e6dfbc5df76f
revset: make matching() preserve input revision order
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Thu May 10 14:17:05 2012 -0400
+++ b/mercurial/revset.py	Wed May 09 18:45:14 2012 +0200
@@ -996,7 +996,7 @@
     # is only one field to match)
     getinfo = lambda r: [f(r) for f in getfieldfuncs]
 
-    matches = []
+    matches = set()
     for rev in revs:
         target = getinfo(rev)
         for r in subset:
@@ -1006,10 +1006,8 @@
                     match = False
                     break
             if match:
-                matches.append(r)
-    if len(revs) > 1:
-        matches = sorted(set(matches))
-    return matches
+                matches.add(r)
+    return [r for r in subset if r in matches]
 
 def reverse(repo, subset, x):
     """``reverse(set)``
--- a/tests/test-revset.t	Thu May 10 14:17:05 2012 -0400
+++ b/tests/test-revset.t	Wed May 09 18:45:14 2012 +0200
@@ -410,6 +410,10 @@
   0
   $ log '4::8 - 8'
   4
+  $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)'
+  2
+  3
+  1
 
 issue2437