Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20288:b61ad01c4e73
revset: use "canonpath()" for "filelog()" pattern without explicit kind
Before this patch, revset predicate "filelog()" uses "match.files()"
to get filename also for the pattern without explicit kind.
But in such case, only canonicalization of relative path is required,
and other initializations of "match" object including regexp
compilation are meaningless.
This patch uses "pathutil.canonpath()" directly for "filelog()"
pattern without explicit kind like "glob:", for efficiency.
This patch also does below as a part of introducing "canonpath()":
- move location of "matchmod.match()" invocation, because "m" is no
more used in "if not matchmod.patkind(pat)" code path
- omit passing "default" argument to "matchmod.match()", because
"pat" should have explicit kind of pattern in this code path
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 17 Jan 2014 23:55:03 +0900 |
parents | f3cef19befb1 |
children | 96be25f1da45 |
comparison
equal
deleted
inserted
replaced
20287:f3cef19befb1 | 20288:b61ad01c4e73 |
---|---|
715 a slower, more accurate result, use ``file()``. | 715 a slower, more accurate result, use ``file()``. |
716 """ | 716 """ |
717 | 717 |
718 # i18n: "filelog" is a keyword | 718 # i18n: "filelog" is a keyword |
719 pat = getstring(x, _("filelog requires a pattern")) | 719 pat = getstring(x, _("filelog requires a pattern")) |
720 m = matchmod.match(repo.root, repo.getcwd(), [pat], default='relpath', | |
721 ctx=repo[None]) | |
722 s = set() | 720 s = set() |
723 | 721 |
724 if not matchmod.patkind(pat): | 722 if not matchmod.patkind(pat): |
725 f = m.files()[0] | 723 f = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
726 fl = repo.file(f) | 724 fl = repo.file(f) |
727 for fr in fl: | 725 for fr in fl: |
728 s.add(fl.linkrev(fr)) | 726 s.add(fl.linkrev(fr)) |
729 else: | 727 else: |
728 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None]) | |
730 for f in repo[None]: | 729 for f in repo[None]: |
731 if m(f): | 730 if m(f): |
732 fl = repo.file(f) | 731 fl = repo.file(f) |
733 for fr in fl: | 732 for fr in fl: |
734 s.add(fl.linkrev(fr)) | 733 s.add(fl.linkrev(fr)) |