Mercurial > hg
comparison mercurial/revset.py @ 20286:760151697a4f
revset: make default kind of pattern for "contains()" rooted at cwd
Before this patch, default kind of pattern for revset predicate
"contains()" is treated as the exact file path rooted at the root of
the repository. This decreases usability, because:
- all other predicates taking pattern argument (also "filelog()")
treat such pattern as the path rooted at the current working
directory
- "contains()" doesn't describe this difference in its help
- this difference may confuse users
for example, this prevents revset aliases from sharing same
argument between "contains()" and other predicates
This patch makes default kind of pattern for revset predicate
"contains()" be rooted at the current working directory.
This patch uses "pathutil.canonpath()" instead of creating "match"
object for efficiency.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 17 Jan 2014 23:42:12 +0900 |
parents | 189fe1b3d16a |
children | f3cef19befb1 |
comparison
equal
deleted
inserted
replaced
20285:189fe1b3d16a | 20286:760151697a4f |
---|---|
10 import node | 10 import node |
11 import match as matchmod | 11 import match as matchmod |
12 from i18n import _ | 12 from i18n import _ |
13 import encoding | 13 import encoding |
14 import obsolete as obsmod | 14 import obsolete as obsmod |
15 import pathutil | |
15 import repoview | 16 import repoview |
16 | 17 |
17 def _revancestors(repo, revs, followfirst): | 18 def _revancestors(repo, revs, followfirst): |
18 """Like revlog.ancestors(), but supports followfirst.""" | 19 """Like revlog.ancestors(), but supports followfirst.""" |
19 cut = followfirst and 1 or None | 20 cut = followfirst and 1 or None |
528 """ | 529 """ |
529 # i18n: "contains" is a keyword | 530 # i18n: "contains" is a keyword |
530 pat = getstring(x, _("contains requires a pattern")) | 531 pat = getstring(x, _("contains requires a pattern")) |
531 s = [] | 532 s = [] |
532 if not matchmod.patkind(pat): | 533 if not matchmod.patkind(pat): |
534 pat = pathutil.canonpath(repo.root, repo.getcwd(), pat) | |
533 for r in subset: | 535 for r in subset: |
534 if pat in repo[r]: | 536 if pat in repo[r]: |
535 s.append(r) | 537 s.append(r) |
536 else: | 538 else: |
537 m = None | 539 m = None |