##// END OF EJS Templates
revset: speedup matching() by stopping the match early if a field does not match...
Angel Ezquerra -
r16445:453c8670 default
parent child Browse files
Show More
@@ -970,19 +970,22 b' def matching(repo, subset, x):'
970 raise error.ParseError(
970 raise error.ParseError(
971 _("unexpected field name passed to matching: %s") % info)
971 _("unexpected field name passed to matching: %s") % info)
972 getfieldfuncs.append(getfield)
972 getfieldfuncs.append(getfield)
973
974 # convert the getfield array of functions into a "getinfo" function
973 # convert the getfield array of functions into a "getinfo" function
975 # which returns an array of field values (or a single value if there
974 # which returns an array of field values (or a single value if there
976 # is only one field to match)
975 # is only one field to match)
977 if len(getfieldfuncs) == 1:
978 getinfo = getfieldfuncs[0]
979 else:
980 getinfo = lambda r: [f(r) for f in getfieldfuncs]
976 getinfo = lambda r: [f(r) for f in getfieldfuncs]
981
977
982 matches = []
978 matches = []
983 for rev in revs:
979 for rev in revs:
984 target = getinfo(rev)
980 target = getinfo(rev)
985 matches += [r for r in subset if getinfo(r) == target]
981 for r in subset:
982 match = True
983 for n, f in enumerate(getfieldfuncs):
984 if target[n] != f(r):
985 match = False
986 break
987 if match:
988 matches.append(r)
986 if len(revs) > 1:
989 if len(revs) > 1:
987 matches = sorted(set(matches))
990 matches = sorted(set(matches))
988 return matches
991 return matches
General Comments 0
You need to be logged in to leave comments. Login now