revset: rename diff(pattern) to diffcontains(pattern) stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 Oct 2020 13:00:04 +0900
branchstable
changeset 45750 c00595736595
parent 45749 f95b16796688
child 45751 60d0634c43c2
revset: rename diff(pattern) to diffcontains(pattern) Suggested by Augie, and I think it's better name.
mercurial/revset.py
tests/test-grep.t
--- a/mercurial/revset.py	Sun Oct 18 22:48:00 2020 -0700
+++ b/mercurial/revset.py	Sat Oct 17 13:00:04 2020 +0900
@@ -994,24 +994,27 @@
     )
 
 
-@predicate(b'diff(pattern)', weight=110)
-def diff(repo, subset, x):
+@predicate(b'diffcontains(pattern)', weight=110)
+def diffcontains(repo, subset, x):
     """Search revision differences for when the pattern was added or removed.
 
     The pattern may be a substring literal or a regular expression. See
     :hg:`help revisions.patterns`.
     """
-    args = getargsdict(x, b'diff', b'pattern')
+    args = getargsdict(x, b'diffcontains', b'pattern')
     if b'pattern' not in args:
-        # i18n: "diff" is a keyword
-        raise error.ParseError(_(b'diff takes at least 1 argument'))
-
-    pattern = getstring(args[b'pattern'], _(b'diff requires a string pattern'))
+        # i18n: "diffcontains" is a keyword
+        raise error.ParseError(_(b'diffcontains takes at least 1 argument'))
+
+    pattern = getstring(
+        args[b'pattern'], _(b'diffcontains requires a string pattern')
+    )
     regexp = stringutil.substringregexp(pattern, re.M)
 
     # TODO: add support for file pattern and --follow. For example,
-    # diff(pattern[, set]) where set may be file(pattern) or follow(pattern),
-    # and we'll eventually add a support for narrowing files by revset?
+    # diffcontains(pattern[, set]) where set may be file(pattern) or
+    # follow(pattern), and we'll eventually add a support for narrowing
+    # files by revset?
     fmatch = matchmod.always()
 
     def makefilematcher(ctx):
@@ -1030,7 +1033,7 @@
                 found = True
         return found
 
-    return subset.filter(testdiff, condrepr=(b'<diff %r>', pattern))
+    return subset.filter(testdiff, condrepr=(b'<diffcontains %r>', pattern))
 
 
 @predicate(b'contentdivergent()', safe=True)
--- a/tests/test-grep.t	Sun Oct 18 22:48:00 2020 -0700
+++ b/tests/test-grep.t	Sat Oct 17 13:00:04 2020 +0900
@@ -23,13 +23,13 @@
 
 invalid revset syntax
 
-  $ hg log -r 'diff()'
-  hg: parse error: diff takes at least 1 argument
+  $ hg log -r 'diffcontains()'
+  hg: parse error: diffcontains takes at least 1 argument
   [255]
-  $ hg log -r 'diff(:)'
-  hg: parse error: diff requires a string pattern
+  $ hg log -r 'diffcontains(:)'
+  hg: parse error: diffcontains requires a string pattern
   [255]
-  $ hg log -r 'diff("re:**test**")'
+  $ hg log -r 'diffcontains("re:**test**")'
   hg: parse error: invalid regular expression: nothing to repeat* (glob)
   [255]
 
@@ -567,13 +567,13 @@
 
 revset predicate for "grep --diff"
 
-  $ hg log -qr 'diff("re:^bl...$")'
+  $ hg log -qr 'diffcontains("re:^bl...$")'
   0:203191eb5e21
-  $ hg log -qr 'diff("orange")'
+  $ hg log -qr 'diffcontains("orange")'
   1:7c585a21e0d1
   2:11bd8bc8d653
   3:e0116d3829f8
-  $ hg log -qr '2:0 & diff("orange")'
+  $ hg log -qr '2:0 & diffcontains("orange")'
   2:11bd8bc8d653
   1:7c585a21e0d1