comparison mercurial/revset.py @ 23061:f2aeff8a87b6 stable

revset: avoid recalculating filesets This fixes a regression in 8dabcc889e33 that moved matcher building into a callback, thus causing it be rebuilt for each revision matched against.
author Matt Mackall <mpm@selenic.com>
date Wed, 22 Oct 2014 15:47:27 -0500
parents c8f32accd00a
children ba89f7b542c9
comparison
equal deleted inserted replaced
23060:4eaea93b3e5b 23061:f2aeff8a87b6
897 # to 'glob'. At most one 'r:' and 'd:' argument can be passed. 897 # to 'glob'. At most one 'r:' and 'd:' argument can be passed.
898 898
899 # i18n: "_matchfiles" is a keyword 899 # i18n: "_matchfiles" is a keyword
900 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument")) 900 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
901 pats, inc, exc = [], [], [] 901 pats, inc, exc = [], [], []
902 hasset = False
903 rev, default = None, None 902 rev, default = None, None
904 for arg in l: 903 for arg in l:
905 # i18n: "_matchfiles" is a keyword 904 # i18n: "_matchfiles" is a keyword
906 s = getstring(arg, _("_matchfiles requires string arguments")) 905 s = getstring(arg, _("_matchfiles requires string arguments"))
907 prefix, value = s[:2], s[2:] 906 prefix, value = s[:2], s[2:]
924 'default mode')) 923 'default mode'))
925 default = value 924 default = value
926 else: 925 else:
927 # i18n: "_matchfiles" is a keyword 926 # i18n: "_matchfiles" is a keyword
928 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix) 927 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
929 if not hasset and matchmod.patkind(value) == 'set':
930 hasset = True
931 if not default: 928 if not default:
932 default = 'glob' 929 default = 'glob'
933 930
931 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
932 exclude=exc, ctx=repo[rev], default=default)
933
934 def matches(x): 934 def matches(x):
935 m = None 935 for f in repo[x].files():
936 c = repo[x]
937 if not m or (hasset and rev is None):
938 ctx = c
939 if rev is not None:
940 ctx = repo[rev or None]
941 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
942 exclude=exc, ctx=ctx, default=default)
943 for f in c.files():
944 if m(f): 936 if m(f):
945 return True 937 return True
946 return False 938 return False
947 939
948 return subset.filter(matches) 940 return subset.filter(matches)