changeset 16640:592e0beee8b0 stable

revset: make matching() preserve input revision order
author Patrick Mezard <patrick@mezard.eu>
date Wed, 09 May 2012 18:45:14 +0200
parents 00290bd359fe
children e6dfbc5df76f
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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