mercurial/revset.py
changeset 16446 984e0412e82b
parent 16445 453c8670566c
child 16452 8a72805034d5
--- a/mercurial/revset.py	Fri Apr 13 13:46:49 2012 +0200
+++ b/mercurial/revset.py	Sat Apr 14 01:41:03 2012 +0200
@@ -950,6 +950,19 @@
         fields.discard('summary')
 
     # We may want to match more than one field
+    # Not all fields take the same amount of time to be matched
+    # Sort the selected fields in order of increasing matching cost
+    fieldorder = ('phase', 'parents', 'user', 'date', 'branch', 'summary',
+        'files', 'description', 'substate',)
+    def fieldkeyfunc(f):
+        try:
+            return fieldorder.index(f)
+        except ValueError:
+            # assume an unknown field is very costly
+            return len(fieldorder)
+    fields = list(fields)
+    fields.sort(key=fieldkeyfunc)
+
     # Each field will be matched with its own "getfield" function
     # which will be added to the getfieldfuncs array of functions
     getfieldfuncs = []