Patchwork [1,of,2] revset: rename diff(pattern) to diffcontains(pattern)

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 17, 2020, 4:56 a.m.
Message ID <ff0d9965fc9db08b95ad.1602910563@mimosa>
Download mbox | patch
Permalink /patch/47492/
State New
Headers show

Comments

Yuya Nishihara - Oct. 17, 2020, 4:56 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1602907204 -32400
#      Sat Oct 17 13:00:04 2020 +0900
# Node ID ff0d9965fc9db08b95ad90523f47fa0cc5f5118e
# Parent  94f681b84c7016289763937cde633cb1d8c831b1
revset: rename diff(pattern) to diffcontains(pattern)

Suggested by Augie, and I think it's better name.
Yuya Nishihara - Oct. 21, 2020, 10:56 a.m.
On Sat, 17 Oct 2020 13:56:03 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1602907204 -32400
> #      Sat Oct 17 13:00:04 2020 +0900
> # Node ID ff0d9965fc9db08b95ad90523f47fa0cc5f5118e
> # Parent  94f681b84c7016289763937cde633cb1d8c831b1
> revset: rename diff(pattern) to diffcontains(pattern)

These patches are intended to be in 5.6.
via Mercurial-devel - Oct. 21, 2020, 3:38 p.m.
Pulkit, do you think you can queue this series? I don't have
queuing-from-email set up.

On Wed, Oct 21, 2020 at 3:59 AM Yuya Nishihara <yuya@tcha.org> wrote:

> On Sat, 17 Oct 2020 13:56:03 +0900, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1602907204 -32400
> > #      Sat Oct 17 13:00:04 2020 +0900
> > # Node ID ff0d9965fc9db08b95ad90523f47fa0cc5f5118e
> > # Parent  94f681b84c7016289763937cde633cb1d8c831b1
> > revset: rename diff(pattern) to diffcontains(pattern)
>
> These patches are intended to be in 5.6.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Pulkit Goyal - Oct. 22, 2020, 10:02 a.m.
On Wed, Oct 21, 2020 at 9:08 PM Martin von Zweigbergk
<martinvonz@google.com> wrote:
>
> Pulkit, do you think you can queue this series? I don't have queuing-from-email set up.

Sure, queuing these for stable. Thank you Yuya!
>
> On Wed, Oct 21, 2020 at 3:59 AM Yuya Nishihara <yuya@tcha.org> wrote:
>>
>> On Sat, 17 Oct 2020 13:56:03 +0900, Yuya Nishihara wrote:
>> > # HG changeset patch
>> > # User Yuya Nishihara <yuya@tcha.org>
>> > # Date 1602907204 -32400
>> > #      Sat Oct 17 13:00:04 2020 +0900
>> > # Node ID ff0d9965fc9db08b95ad90523f47fa0cc5f5118e
>> > # Parent  94f681b84c7016289763937cde633cb1d8c831b1
>> > revset: rename diff(pattern) to diffcontains(pattern)
>>
>> These patches are intended to be in 5.6.
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -994,24 +994,27 @@  def destination(repo, subset, x):
     )
 
 
-@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 @@  def diff(repo, subset, x):
                 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)
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -23,13 +23,13 @@  pattern error
 
 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 @@  Test wdir
 
 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