# HG changeset patch # User Patrick Mezard # Date 2012-05-09 16:45:14 # Node ID 592e0beee8b0d07298943f87b1a117c049f53fd0 # Parent 00290bd359feb4c7a0e143db021808497c42d6c2 revset: make matching() preserve input revision order diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -996,7 +996,7 @@ def matching(repo, subset, x): # 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 @@ def matching(repo, subset, x): 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)`` diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -410,6 +410,10 @@ quoting needed 0 $ log '4::8 - 8' 4 + $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)' + 2 + 3 + 1 issue2437