changeset 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
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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)'