Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20453:6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Performance benchmarking:
$ time hg log -qr "first(grep(hg))"
0:9117c6561b0b
real 0m2.214s
user 0m2.163s
sys 0m0.045s
$ time ./hg log -qr "first(grep(hg))"
0:9117c6561b0b
real 0m0.211s
user 0m0.146s
sys 0m0.035s
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 30 Jan 2014 16:03:18 -0800 |
parents | a685d9870eb5 |
children | 47fd57f650e5 |
comparison
equal
deleted
inserted
replaced
20452:a685d9870eb5 | 20453:6aa7dcae6bd8 |
---|---|
798 try: | 798 try: |
799 # i18n: "grep" is a keyword | 799 # i18n: "grep" is a keyword |
800 gr = re.compile(getstring(x, _("grep requires a string"))) | 800 gr = re.compile(getstring(x, _("grep requires a string"))) |
801 except re.error, e: | 801 except re.error, e: |
802 raise error.ParseError(_('invalid match pattern: %s') % e) | 802 raise error.ParseError(_('invalid match pattern: %s') % e) |
803 l = [] | 803 |
804 for r in subset: | 804 def matches(x): |
805 c = repo[r] | 805 c = repo[x] |
806 for e in c.files() + [c.user(), c.description()]: | 806 for e in c.files() + [c.user(), c.description()]: |
807 if gr.search(e): | 807 if gr.search(e): |
808 l.append(r) | 808 return True |
809 break | 809 return False |
810 return baseset(l) | 810 |
811 return lazyset(subset, matches) | |
811 | 812 |
812 def _matchfiles(repo, subset, x): | 813 def _matchfiles(repo, subset, x): |
813 # _matchfiles takes a revset list of prefixed arguments: | 814 # _matchfiles takes a revset list of prefixed arguments: |
814 # | 815 # |
815 # [p:foo, i:bar, x:baz] | 816 # [p:foo, i:bar, x:baz] |