revset: make default kind of pattern for "contains()" rooted at cwd
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 17 Jan 2014 23:42:12 +0900
changeset 20286 760151697a4f
parent 20285 189fe1b3d16a
child 20287 f3cef19befb1
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.
mercurial/revset.py
tests/test-revset.t
--- 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)'