# HG changeset patch # User FUJIWARA Katsunori # Date 1389969732 -32400 # Node ID 760151697a4fe2ea4c4c98565dddba4c5df69186 # Parent 189fe1b3d16ae0035424cedce46a5b7b542644ba 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. diff -r 189fe1b3d16a -r 760151697a4f mercurial/revset.py --- a/mercurial/revset.py Fri Jan 17 23:42:12 2014 +0900 +++ b/mercurial/revset.py Fri Jan 17 23:42:12 2014 +0900 @@ -12,6 +12,7 @@ from i18n import _ import encoding import obsolete as obsmod +import pathutil import repoview def _revancestors(repo, revs, followfirst): @@ -530,6 +531,7 @@ pat = getstring(x, _("contains requires a pattern")) s = [] if not matchmod.patkind(pat): + pat = pathutil.canonpath(repo.root, repo.getcwd(), pat) for r in subset: if pat in repo[r]: s.append(r) diff -r 189fe1b3d16a -r 760151697a4f tests/test-revset.t --- a/tests/test-revset.t Fri Jan 17 23:42:12 2014 +0900 +++ b/tests/test-revset.t Fri Jan 17 23:42:12 2014 +0900 @@ -273,6 +273,11 @@ 1 3 5 + $ log 'contains("../repo/a")' + 0 + 1 + 3 + 5 $ log 'desc(B)' 5 $ log 'descendants(2 or 3)'